Skip to content

Instantly share code, notes, and snippets.

@TarasShu
Created July 2, 2020 13:52
Show Gist options
  • Save TarasShu/b4845226987eacda0662771f9b9f8220 to your computer and use it in GitHub Desktop.
Save TarasShu/b4845226987eacda0662771f9b9f8220 to your computer and use it in GitHub Desktop.
let mainLayer = CALayer()
mainLayer.frame = CGRect(x: 0, y: 0, width: 500, height: 500)
mainLayer.backgroundColor = CGColor(red: 100.0/255.0, green: 130.0/255.0, blue: 230.0/255.0, alpha: 1.0)
let layer = CALayer()
layer.frame = CGRect(x: 250, y: 250, width: 100, height: 100)
layer.backgroundColor = CGColor(srgbRed: 10.0, green: 50.0, blue: 10.0, alpha: 100.0)
let oneLayer = CALayer()
oneLayer.frame = CGRect(x: 300, y: 300, width: 50, height: 50)
oneLayer.backgroundColor = CGColor(red: 100.0/100.0, green: 130.0/150.0, blue: 230.0/100.0, alpha: 1.0)
layer.addSublayer(oneLayer)
mainLayer.addSublayer(layer)
mainLayer.render(in: context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment