Skip to content

Instantly share code, notes, and snippets.

@douglastaquary
Created December 7, 2017 14:38
Show Gist options
  • Save douglastaquary/237da320ffb9388f392c7a3d63ae983a to your computer and use it in GitHub Desktop.
Save douglastaquary/237da320ffb9388f392c7a3d63ae983a to your computer and use it in GitHub Desktop.
fileprivate func roundMask() -> CAShapeLayer {
let px = avatarView.bounds.midX
let py = avatarView.bounds.midY
let frame = CGRect(x: -px, y: -py, width: avatarView.bounds.width, height: avatarView.bounds.height)
let path = UIBezierPath(ovalIn: frame)
let rm = CAShapeLayer()
rm.path = path.cgPath
rm.fillColor = UIColor.red.cgColor
rm.position = CGPoint(x: px, y: py)
rm.transform = CATransform3DMakeScale(0.01, 0.01, 1)
return rm
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment