iphone - stretchableImageWithLeftCapWidth 导致角落模糊

标签 iphone objective-c ios xcode

我有一个盒子,我只想在其宽度上进行扩展,同时仍保持我拥有的圆角。我在 photoshop 中制作了图形。它正好是 13px 宽,所以每个角 6 个,中间 1 个重复。

UIImage* img = [[UIImage imageNamed:@"screen_displayer_rounded.png"] stretchableImageWithLeftCapWidth:6 topCapHeight:6];
    CGRect rect = CGRectMake(272.0f, 14.0f, 100.0f, 30.0f);
    UIImageView* imgView = [[UIImageView alloc] initWithFrame:rect];
    [imgView setImage:img];

谁能告诉我为什么会这样?

谢谢!

最佳答案

我发现您不能仅依靠 stretchableImageWithLeftCapWidth 来正确调整大小。

当 stretchableImageWithLeftCapWidth 对我不起作用时,我通常使用可用于所有 UIView 子类的 contentStretch 属性。

查看有关 contentStretch 属性的 UIView 苹果文档。

关于iphone - stretchableImageWithLeftCapWidth 导致角落模糊,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7327517/

相关文章:

iphone - 获取 UITextField 中填写的 5 个最近项目的列表

ios - CAShapeLayer mask 从底部显示

iphone - 由于 iPhone 中的默认调用,UI 受到干扰

ios - iOS 8 上的自动布局约束

iOS:发送带有请求的 If Modified Since header

ios - 为什么 drawRect : will adversely affect performance during animation 的空实现

iphone - 如何查找访问量最高的 20 个项目并将其添加为收藏夹

iphone - Xcode 语法突出显示的问题

iPhone签名捕捉

ios - 尝试将来自 Web API 的照片添加到表中的各个行