Skip to content

Instantly share code, notes, and snippets.

@danie7k
Created April 10, 2017 13:46
Show Gist options
  • Save danie7k/fbb7bfb7e33e5e6e4bc8226c580ca38f to your computer and use it in GitHub Desktop.
Save danie7k/fbb7bfb7e33e5e6e4bc8226c580ca38f to your computer and use it in GitHub Desktop.
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