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

Exploring layers


Layers are behind almost all the views you encounter in iOS, and they are the very base of anything you do with core animation.

The CALayer class represents layers, and their main role is presenting content in a lightweight mode. The content is almost never drawn by the layer itself, but it is received as a bitmap, cached in a backing store, and then presented. You should look at layers as model objects rather than drawing elements; if there are any exceptions, it's probably because layers store the information needed to present some content generated somewhere else.

Layers and views

When a UIView class is instantiated, it sets its layer property with an instance of CALayer that, under the hood, contains a backed bitmap version of the view. This method ensures an efficient and lightweight solution to draw and animate contents.

A relationship between the layer and view is immediately created during initialization, and the view becomes the delegate of the layer. From now on, a...