NSError
NSError

Reputation: 175

About UIImageView with round corners

I'm trying to make a UIImageView with round corners, so I used [imageView.layer setCornerRadius:5.0f]; it works but not perfectly.

If you look closely, you can see the corners of the image(I uploaded a photo, I don't know if you can see it clearly, there are blue parts in the corners). How should I remove these? thank you.

(P.S.: I also set the border of the view, is that the reason why?)

image

Upvotes: 0

Views: 86

Answers (1)

jackslash
jackslash

Reputation: 8570

UIImageView doesn't clip to bounds by default. So while the corner radius is applied its still drawing outside of its designated area.

objc:

[imageView setClipsToBounds:YES];

swift:

imageView.clipsToBounds = true

Upvotes: 4

Related Questions