UIView subclass has a built-in way to draw a border around it using its underlying
CALayer. For example, to draw a 10-point black border around a view, you'd use this:... Continue Reading >>
Keyframe animations offer extraordinary power for developers because they let you set multiple values and have iOS animate between them over times you specify. There are three components: a key path (the property to animate), an array of values (the value you want to use for that property), and an array of key times (when that value should be used for the property).... Continue Reading >>
CAGradientLayer because it takes just four lines of code to use, and yet looks great because it quickly and accurately draws smooth color gradients use Core Graphics. Here's a basic example:... Continue Reading >>
There are lots of
CALayer subclasses out there, but
CAShapeLayer is one of my favorites: it provides hardware-accelerated drawing of all sorts of 2D shapes, and includes extra functionality such as fill and stroke colors, line caps, patterns and more.... Continue Reading >>
Believe it or not, iOS has a built-in particle system that works great in all UIKit apps and is immensely customizable. To get started you need to create a
CAEmitterLayer object and tell it how to create particles: where it should create them, how big the emitter should be, and what types of particles should exist.... Continue Reading >>
UIView subclasses have the ability to round their corners thanks to their underlying
CALayer – that's the bit that handles the actual drawing of your views. To round the corners of a view, use this code:... Continue Reading >>
About the Swift Knowledge Base
This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions, all written for Swift 4.
Help support Hacking with Swift
This site is funded by Hacking with Swift supporters who buy my e-books. If you can, please support my work – it comes packed with bonus material!