Created
April 10, 2017 13:46
-
-
Save danie7k/fbb7bfb7e33e5e6e4bc8226c580ca38f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
func roundImage(image: Image) -> Image? { | |
let rect = CGRect(origin:CGPoint(x: 0, y: 0), size: image.size) | |
UIGraphicsBeginImageContextWithOptions(image.size, false, 0.0) | |
UIBezierPath(roundedRect: rect, cornerRadius: self.cornerRadius).addClip() | |
image.draw(in: rect) | |
let roundedImage = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
return roundedImage | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment