Book Image

Swift Essentials - Second Edition

By : Alex Blewitt
Book Image

Swift Essentials - Second Edition

By: Alex Blewitt

Overview of this book

Swift was considered one of the biggest innovations last year, and certainly with Swift 2 announced at WWDC in 2015, this segment of the developer space will continue to be hot and dominating. This is a fast-paced guide to provide an overview of Swift programming and then walks you through in detail how to write iOS applications. Progress through chapters on custom views, networking, parsing and build a complete application as a Git repository, all by using Swift as the core language
Table of Contents (17 chapters)
Swift Essentials Second Edition
About the Author
About the Reviewer

Custom graphics with layers

Drawing graphics by overriding drawRect is not very performant because all the drawing routines are executed on the CPU. Offloading the graphics drawing to the GPU is both more performant and more power efficient.

iOS has a concept of layers, which are Core Graphics optimized drawing contents. Operations composed on a layer, including adding a path, can be translated into code that can execute on the GPU and be rendered efficiently. In addition, Core Animation can be used to animate changes on layers efficiently. Core Animation is provided in the QuartzCore framework/module; the two terms are interchangeable. It is more generally known as Core Animation.

The download progress icon on iOS can be recreated as a ProgressView containing layers for the circular outline, a layer for the square stop button in the middle, and a layer for the progress arc. The final view will composite these three layers together to provide the finished view.

Every UIView has an implicit...