可能重複:
How to develop or migrate apps for iPhone 5 screen resolution?如何創建iPhone應用程序是適用於iPhone 4和5的屏幕尺寸共通性
我有兩套images.One組圖像到iPhone 4背景圖像和其他圖像集合到iphone 5.我可以如何使用這兩個圖像集來創建我的iPhone應用程序,它想要兼容兩種屏幕尺寸? 我想檢查iPhone版本,並使用一些編碼應用圖像? 希望你能幫忙。謝謝你的幫助。
可能重複:
How to develop or migrate apps for iPhone 5 screen resolution?如何創建iPhone應用程序是適用於iPhone 4和5的屏幕尺寸共通性
我有兩套images.One組圖像到iPhone 4背景圖像和其他圖像集合到iphone 5.我可以如何使用這兩個圖像集來創建我的iPhone應用程序,它想要兼容兩種屏幕尺寸? 我想檢查iPhone版本,並使用一些編碼應用圖像? 希望你能幫忙。謝謝你的幫助。
我使用的類擴展名爲。你可以在這裏找到來源:https://github.com/erica/uidevice-extension
我已經設置了一個整潔的小方法,根據屏幕大小布局視圖。 例子:
- (void)setupGUI
{
UIImage *backgroundImage;
if ([[UIDevice currentDevice] platformType] == UIDevice5iPhone)
{
//4 inch screen
backgroundImage = [[UIImage alloc] initWithCGImage:[UIImage imageNamed:@"[email protected]"].CGImage scale:2.0 orientation:UIImageOrientationUp];
}
else
{
//3.5 inch screen
backgroundImage = [[UIImage imageNamed:@"main_background"] retain];
}
self.view.backgroundColor = [UIColor colorWithPatternImage:backgroundImage];
[backgroundImage release];
}
閃現,你可以使用後綴[email protected]
對於UIImage的,你可以使用:
[UIImage imageNamed:@"tryImage"]
而且你可以擁有tryImage.png
,[email protected]
和[email protected]
,但似乎沒有按照我們的願望工作。
您也可以使用這樣的伎倆:https://gist.github.com/3782351
感謝您的回覆,:)是的,我有這3種背景圖片(tryImage.png,tryImage @ 2x.png,tryImage-568h @ 2X的如果我使用ios6版本來創建我的應用程序,那麼當我得到一個新的xib時,我得到一個具有568屏幕高度的視圖。所以,仍然要使用tryImage.png作爲默認背景那種觀點還是我需要使用[email protected]? – harshiYL
我有一個新的xib,我添加了一個imageView,它的視圖高度相同(568),我用tryImage.png作爲它的背景圖片。它是正確的嗎? – harshiYL