Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to crop UIImage on oval shape or circle shape?

Please give ideas for how to crop UIImage on oval shape or circle shape. Please share your ideas.

like image 921
Ramkumar Paulraj Avatar asked Jun 30 '11 06:06

Ramkumar Paulraj


People also ask

How do I change a picture from a square to an oval?

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.

How do you Crop a picture into a circle in Powerpoint?

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.


1 Answers

#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 
like image 151
Rakesh Bhatt Avatar answered Oct 09 '22 23:10

Rakesh Bhatt