【问题标题】:UIImageView corner radius results in gray unwanted sharp angleUIImageView 角半径导致灰色不需要的锐角
【发布时间】:2016-12-27 00:18:04
【问题描述】:

我想知道为什么设置 ImageView 的圆角半径会导致灰色的不需要的锐角,像这样

注意到圆角图像后面有锐利的灰色角。 我这样设置角半径:

 self.previewImageView.image = videoStream.thumbImage;
 self.previewImageView.layer.cornerRadius = 8.0;
 self.previewImageView.clipsToBounds = YES;
 self.previewImageView.layer.masksToBounds = YES;

我还确保图像视图的背景颜色为白色,但无论如何它都无济于事。

有人知道如何在设置图像视图的圆角时摆脱锐利的灰色角度吗?

我知道我可能会画一条路径并设置图层的蒙版路径,有没有其他选择?

我的背景视图是一个集合视图单元格,恰好与 imageView 大小不同,我不能只设置背景视图的角半径

【问题讨论】:

  • 确保您的图片默认没有灰色边框。尝试在浏览器或任何地方打开它并检查一次。
  • 不,没有
  • UIImageView 后面是哪个视图,它的颜色是什么?

标签: ios objective-c uiimageview


【解决方案1】:

尝试将图像视图的背景颜色设置为清除。

【讨论】:

  • 我试过self.previewImageView.backgroundColor = [UIColor clearColor],但它不起作用
【解决方案2】:

只是做:-

self.yourBackgroundView.layer.cornerRadius=self.yourImageView.layer.cornerRadius

【讨论】:

  • 我的背景视图是一个集合视图单元格,恰好与imageView的大小不同,我不能只设置我的背景视图的角半径
  • 对collectionviewcell应用圆角半径,比那样简单:)。
  • 我说单元格不只是被imageView占用。假设单元格为100 * 120,图片为100 * 100,上下对齐,不能只设置单元格的圆角半径,它只适用于上上两个角,而imageView的下角保持原样。
  • 没有代码就无法判断这里出了什么问题。
【解决方案3】:

你可以试试下面的代码 --

self.previewImageView.layer.borderColor = (__bridge CGColorRef)([UIColor clearColor]);

希望这篇文章对您有所帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-05-17
    • 1970-01-01
    • 2023-03-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多