Please give ideas for how to crop UIImage
on oval shape or circle shape. Please share your ideas.
Select the photo in the document to make the Format menu beneath Picture Tools appear. Click the "Format" menu, then "Crop" and select the "Crop to Shape" option that appears in the drop-down menu. Clicking the "Oval" in the list of shapes crops the photo into an oval.
If you want to change the outline of a picture and make it a shape (like a circle or a star), use the cropping tools on the PICTURE TOOLS FORMAT tab. Select the picture (or pictures) that you want to crop. On the PICTURE TOOLS FORMAT tab, click Crop > Crop to Shape, and then pick the shape you want.
#import <QuartzCore/QuartzCore.h> CALayer *imageLayer = YourImageview.layer; [imageLayer setCornerRadius:5]; [imageLayer setBorderWidth:1]; [imageLayer setMasksToBounds:YES];
by increasing radius it will become more round-able.
As long as the image is a square, you can get a perfect circle by taking half the width as the corner radius:
[imageView.layer setCornerRadius:imageView.frame.size.width/2];
You also need to add
[imageView.layer setMasksToBounds:YES];
Swift 4.2
import QuartzCore var imageLayer: CALayer? = YourImageview.layer imageLayer?.cornerRadius = 5 imageLayer?.borderWidth = 1 imageLayer?.masksToBounds = true
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With