我在xCode 5中创建了一个新的iOS项目,部署目标为6.0,并应用“底部空间到父视图”的“Pin”约束,以使AutoLayout适用于iOS 7和不同的iOS 6.0设备。但是,当我选择选项“View as :”:“iOS 7.0及更高版本”时,按钮看起来如下所示:
然后,当我将选项“View as :”更改为“iOS 6.0及更早版本”时,按钮看起来如下所示:
我该如何管理约束,使其适用于iOS 6.0和iOS 7.0?
提前感谢您的帮助!
![enter image description here](https://istack.dev59.com/X3dBK.webp)
![enter image description here](https://istack.dev59.com/0wW43.webp)
提前感谢您的帮助!
我正在开发一款可以在iOS 6和iOS 7上运行的应用程序。我的一些按钮在iOS 6和iOS 7上看起来相同,而另一些按钮在iOS 6上垂直缩小但在iOS 7上正常。我查看了一下,发现区别在于那些保持大小的按钮上,我使用了背景图像。
//...background button images are 33wx44h and 66wx88h. these correspond to the
// two name variations; <name>.png and <name>@2x.png. the former is used for
// standard resolution screens and the latter for retina screens.
// the UIEdgeInsetsMake is specifically set to 0, 16, 0, 16 (tp,lf,by,rt) so
// that we have no vertical stretching because Apple's preferred button size,
// vertically, is 44. horizontally, the button is 33w and we lock 16 from
// the left and 16 from the right to leave only a single vertical row of pixels
// to be stretched horozontally; which is the most efficient; processing wise.
UIEdgeInsets insets = UIEdgeInsetsMake( 00.0f,16.0f,00.0f,16.0f ); // tp,lf,bt,rt
UIIMage * btnImage = [[UIImage imageNamed: myImage ]
resizableImageWithCapInsets: insets];
[button setBackgroundImage: btnImage
forState: UIControlStateNormal];
我在思考,在我的情况下,即使是透明的,我也可以在所有这些元素中放置一个背景图片,以保持相同的外观。
希望对您有所帮助。