2015-01-07 109 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