制作iphone app .xib文件适合iphone 5 4英寸屏幕

时间:2013-05-28 18:37:46

标签: iphone xcode interface-builder

如何使UIImageView适合Retina 4英寸显示屏?谢谢。 enter image description here

1 个答案:

答案 0 :(得分:0)

如果您正在为iOS 6开发应用,请使用 Autolayouts 。 否则,如果通过NIB管理高度,则可以使用 AutoResizing 功能。

如果您想以编程方式管理它,可以使用以下代码:

#define IS_IPHONE ( [[[UIDevice currentDevice] model] isEqualToString:@"iPhone"])
#define IS_HEIGHT_GTE_568 [[UIScreen mainScreen ] bounds].size.height >= 568.0f
#define IS_IPHONE_5 ( IS_IPHONE && IS_HEIGHT_GTE_568 )

然后将框架设置为:

[your_imageview setFrame:CGRectMake(0.0f, 0.0f, 320.0f, IS_IPHONE_5?568.0f:480.0f)];

希望它对你有所帮助。