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

UIKit helpers


Before starting with code, let's have a look at some of the tools provided by UIKit to simplify the drawing process with core graphics. All the functionalities that we will list in this section produce results that can be achieved with core graphics in its "pure" form. You can view these UIKit helpers as shortcuts to some more complex core graphics functions. UIKit and core graphics elements can be easily distinguished by the prefixes of the classes and function names—UI for UIKit and CG for core graphics. You can find all the following code examples in the source code of the chapter.

Drawing with fill and stroke options

The UIKit helpers can be used to alter the current graphic state by defining the current color for fill and stroke drawing actions. These functionalities are part of the UIColor class with its setFill(), setStroke(), and set() functions (the last sets both the stroke and fill colors). Execute the following code:

override func drawRect(rect: CGRect) {
    drawRedRect...