Skip to content

Instantly share code, notes, and snippets.

@bitops
Created July 19, 2014 06:31
Show Gist options
  • Save bitops/11c0d7c1a5546473c7c7 to your computer and use it in GitHub Desktop.
Save bitops/11c0d7c1a5546473c7c7 to your computer and use it in GitHub Desktop.
// get your image
var image = UIImage(named: "image.jpg")
// begin a new image
UIGraphicsBeginImageContextWithOptions(imageView.bounds.size, false, UIScreen.mainScreen().scale)
// add a clip in the shape of a rounded rectangle
UIBezierPath(roundedRect: imageView.bounds, cornerRadius: 10.0).addClip()
// draw the image in the view
image.drawInRect(imageView.bounds)
// set the image
imageView.image = UIGraphicsGetImageFromCurrentImageContext()
// clean up
UIGraphicsEndImageContext()
@jjb3rd
Copy link

jjb3rd commented Oct 21, 2015

//This makes an ImageView rounded....
imageView.layer.cornerRadius = imageView.frame.size.width / 2
imageView.clipsToBounds = true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment