Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make UIImageView as a circle [iOS]

Tags:

ios

I have an UIImageView. I want to make it as a circle type and 5 pixel red color border around it.

How it is possible? I share code and image also. Please anybody help me ?

enter image description here

My code is:

UIImageView *myImageview = [[UIImageView alloc] initWithFrame:CGRectMake(130, 200, 60, 60)];
[myImageview setImage:[UIImage imageNamed:@"image.png"]];
[self.view addSubview:myImageview];
like image 361
user3631436 Avatar asked Dec 08 '22 07:12

user3631436


1 Answers

Simply you can make it.

Just follow this code..

#import <QuartzCore/QuartzCore.h>

[myImageview.layer setBorderColor:[[UIColor redColor] CGColor]]; // For border color
[myImageview.layer setBorderWidth:5.0]; // For Border width
[myImageview.layer setCornerRadius:45.0f]; // For Corner radious
[myImageview.layer setMasksToBounds:YES];
like image 141
Soumya Ranjan Avatar answered Dec 11 '22 09:12

Soumya Ranjan