Skip to content

Instantly share code, notes, and snippets.

@alexnikol
Created April 26, 2020 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexnikol/a1f1ca88b3335b8b35c98393069a4760 to your computer and use it in GitHub Desktop.
Save alexnikol/a1f1ca88b3335b8b35c98393069a4760 to your computer and use it in GitHub Desktop.
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