CALayer Fundamentals
Work with layers, their properties, and hierarchy.
What Is a CALayer?
CALayer is the backing store for everything you see in UIKit. Each UIView is drawn by a layer that holds its visual content as a texture on the GPU.
Working with layers directly unlocks hardware-accelerated graphics and animation.
import UIKit
let layer = CALayer()Layers Behind Views
Every view has a layer property. Setting layer properties is often simpler and cheaper than custom drawing.
view.layer.cornerRadius = 12
view.layer.masksToBounds = true