我有一个盒子,我只想在其宽度上进行扩展,同时仍保持我拥有的圆角。我在 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/