如何在Xcode中使用约束将UIImageview自动拉伸到100%

时间:2013-07-31 02:41:34

标签: uiimage interface-builder

我无法弄清楚如何让UIImage拉伸任何给定iPhone / iPad方向的宽度并保持宽高比。

这甚至可能吗?

1 个答案:

答案 0 :(得分:0)

您可以尝试使用

stretchableImageWithLeftCapWidth:(NSInteger)leftCapWidth topCapHeight:(NSInteger)topCapHeight

所以它是这样的:

UIImage *image = [UIImage imageNamed:@"Name"] stretchableImageWithLeftCapWidth:self.view.frame.size.width topCapHeight:1.0];

没有经过测试的代码,但它是为了帮助向您展示使用它的可能性

希望有所帮助!