2015-01-07 108 views
0

是否有任何方法可以调整所有屏幕尺寸的背景图像,而不是使用该程序?根据屏幕尺寸调整背景图像

+1

你能至少向我们展示一些代码/你如何实现背景图像?你在故事板中使用'UIImageView'来显示背景图片吗? – Raptor

+0

是你使用autolayout吗? – codercat

回答

0

可以设置UIImageview contentmode到AspectFill/AspectFit在厦门国际银行/故事板其他明智的你做编程这样

imageView.contentMode = UIViewContentModeScaleAspectFill; //填满整个画面,可能是切断你的图像部分

imageView.contentMode = UIViewContentModeScaleAspectFit; //显示整个图像,可能会使框架的区域打开

+0

怎么可能?您是否阅读过苹果ui指南,因为每个屏幕尺寸都基于@ 2x,@ 3x等分辨率。它认为这不太顺利 – codercat

0

可以在故事板文件中使用自动布局并为图像设置属性是AspectFit的AspectFill。

0

我不确定这是不错的做法。如果有人知道可以分享。

这是仅适用于iOS7以上。

#define isPhone568 ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 568) 
#define isPhone667 ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 667) 
#define iPhone568ImageNamed(image) (isPhone568 ? [NSString stringWithFormat:@"%@-568h.%@", [image stringByDeletingPathExtension], [image pathExtension]] : isPhone667 ? [NSString stringWithFormat:@"%@-667h.%@", [image stringByDeletingPathExtension], [image pathExtension]]:image) 

iPhone 5的屏幕尺寸 - 568
iPhone 6屏幕尺寸 - 667
iPhone 6+使用 - 像@ 3个
其他人使用 - 像@ 2X