Skip to content

Instantly share code, notes, and snippets.

@alexnikol
Created Apr 26, 2020
Embed
What would you like to do?
Add sublayers to layer of UIView
// MARK: Creation of sublayer1
let sublayer1 = CALayer()
sublayer1.frame = CGRect(x: 20, y: 20, width: 30, height: 30)
sublayer1.backgroundColor = UIColor.red.cgColor
// MARK: Creation of sublayer2
let sublayer2 = CALayer()
sublayer2.frame = CGRect(x: 80, y: 80, width: 40, height: 40)
sublayer2.backgroundColor = UIColor.green.cgColor
//Adding of sublayers to view.layer
view.layer.addSublayer(sublayer1)
view.layer.addSublayer(sublayer2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment