关于带圆角的UIImageView [英] About UIImageView with round corners

查看:114
本文介绍了关于带圆角的UIImageView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用圆角制作UIImageView,所以我使用了[imageView.layer setCornerRadius:5.0f];它有效但不完美。

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.

(PS:我也设置了视图的边框,这是为什么?)

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

推荐答案

UIImageView 默认情况下不会剪切到边界。因此,当应用角半径时,其仍然在其指定区域之外绘制。

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

这篇关于关于带圆角的UIImageView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆