Skip to content

Instantly share code, notes, and snippets.

@nderkach
Created June 16, 2017 17:36
Show Gist options
  • Save nderkach/49b05abec479d34d2413506f5e3e9e6a to your computer and use it in GitHub Desktop.
Save nderkach/49b05abec479d34d2413506f5e3e9e6a to your computer and use it in GitHub Desktop.
iOS: set UIImage mask
let maskLayer = CALayer()
let maskImage = UIImage(named: "avatar-mask")?.cgImage
maskLayer.frame = CGRect(x: 0, y: 0, width: profileImageView.bounds.size.width, height: profileImageView.bounds.size.height)
maskLayer.contents = maskImage;
profileImageView.layer.mask = maskLayer
profileImageView.layer.masksToBounds = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment