Created
June 16, 2017 17:36
-
-
Save nderkach/49b05abec479d34d2413506f5e3e9e6a to your computer and use it in GitHub Desktop.
iOS: set UIImage mask
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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