Skip to content

Instantly share code, notes, and snippets.

@KentarouKanno
Last active December 26, 2015 13:56
Show Gist options
  • Save KentarouKanno/618e3443b204be509043 to your computer and use it in GitHub Desktop.
Save KentarouKanno/618e3443b204be509043 to your computer and use it in GitHub Desktop.

CALayer

★ CALayer生成例

let layer = CALayer()
layer.backgroundColor = UIColor.blueColor().CGColor
layer.shadowOffset = CGSizeMake(0, 3)
layer.shadowRadius = 5.0
layer.shadowColor = UIColor.blackColor().CGColor
layer.shadowOpacity = 0.8
layer.frame = CGRectMake(30, 30, 120, 150)
layer.borderColor = UIColor.blackColor().CGColor
layer.borderWidth = 2.0
layer.cornerRadius = 10.0
self.view.layer.addSublayer(layer)

★ position

let view = UIView(frame: CGRectMake(50, 50, 100, 100))

let anchorPoint = view.layer.anchorPoint
//=> CGPoint(0.5, 0.5) Default

view.layer.position = CGPoint(x:100, y: 100)
// position = view.frame.origin + view.frame.size * anchorPoint

view.center = CGPoint(x:100, y: 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment