Book Image

Learning iOS UI Development

Book Image

Learning iOS UI Development

Overview of this book

Through this comprehensive one-stop guide, you’ll get to grips with the entire UIKit framework and in a flash, you’ll be creating modern user interfaces for your iOS devices using Swift. Starting with an overview of the iOS drawing system and the available tools, you will then learn how to use these technologies to create adaptable layouts and custom elements for your applications. Next, you’ll be introduced to other topics such as animation and code-drawing with Core Graphics, which will give you all the knowledge you need to create astonishing user interfaces. By the end of this book, you will have a solid foundation in iOS user interface development and will have gained valuable insights on the process of building firm and complex UIs.
Table of Contents (16 chapters)
Learning iOS UI Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Sending actions


The ThermostatSlider implementation is almost complete; we are just missing a way to communicate the change of the current value, exactly as a common UISlider class does with the object subscribed to its value update.

The UIControl class provides methods to handle the target-action pattern in a really easy way; you can add a new target object with addTarget(_:action:forControlEvents:) specifying the action and event to which to subscribe. Then, you can remove this with the removeTarget(_:action:forControlEvents:) method. The list of targets subscribed to the control events can be retrieved using the allTargets() method. You can even obtain the name of the action called when a given event is triggered on a target using actionsForTarget(_:forControlEvent:). The method we will use to inform subscribed objects that our control value is updated is sendActionsForControlEvents(_:). You encountered this at the end of the implementation of the setter for the value property:

self.sendActionsForControlEvents...