gpt4 book ai didi

iOS:图像在 UIImageView 中显示不正确

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:00:43 24 4
gpt4 key购买 nike

我有一个 UIImageView,其中显示了一个来自 JSON 的 UIImage。问题是我想为 UIImageView 设置 cornerRadius。我为此输入了以下代码:

imgVw.layer.cornerRadius = 30.0;
imgVw.layer.borderWidth = 2.0;
imgVw.layer.borderColor = [UIColor blackColor].CGColor;

它显示 cornerRadiusUIImageView 的边框,但显示方式不正确。图像显示在角落外,如屏幕截图所示。

enter image description here

最佳答案

你需要像这样将layermasksToBounds属性设置为YES

self.imgVw.layer.masksToBounds = YES;

关于iOS:图像在 UIImageView 中显示不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38259224/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com