tranvutuan
tranvutuan

Reputation: 6109

how to round corner of an image

In order to round the corner of an image, I am doing the following

UIImageView     *myView     =   [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, size.width, size.height)];
[myView setImage:[UIImage imageNamed:@"xcode_57X57"]];
myView.layer.cornerRadius      =   10.0;
myView.layer.borderWidth       =   1.0;
myView.layer.borderColor       =   [UIColor blueColor].CGColor;
myView.layer.shadowRadius      =   8;

However, what I got is the corners of myView are rounded but the corners of an image. The image below shows my issue.

If you encountered this problem before, please advice me on this.

enter image description here

Upvotes: 2

Views: 195

Answers (1)

tipycalFlow
tipycalFlow

Reputation: 7644

You need to clip subviews:

myView.clipsToBounds = TRUE;

Upvotes: 6

Related Questions