user2951348
user2951348

Reputation: 113

Draw an ellipse or circle inside a UIImageView

I have an image created and I want to draw a ellipse or circle on it with parameters X coordinates, Y coordinates, Width and Height. I've search on google and found out that you can't draw inside a UI Image View.

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tom.jpg"]];

[self.view addSubview:imageView];

And can I add a filter effect like blur inside where I draw the ellipse or circle?

Upvotes: 1

Views: 478

Answers (1)

Rajeev
Rajeev

Reputation: 5002

Refer this well explained article : http://www.appcoda.com/ios-programming-circular-image-calayer/

Creating a Circular Profile Image :

self.profileImageView.layer.cornerRadius = self.profileImageView.frame.size.width / 2;
self.profileImageView.clipsToBounds = YES;

Adding Border :

self.profileImageView.layer.borderWidth = 3.0f;
self.profileImageView.layer.borderColor = [UIColor whiteColor].CGColor;

Creating Rounded Corner Image :

self.profileImageView.layer.cornerRadius = 10.0f;

Upvotes: 1

Related Questions