在我的應用程序的首頁,我有兩個圖像,它們放置在兩個按鈕的一部分上。這些按鈕會自動縮放(通過取決於iPhone屏幕的大小)。不幸的是,當圖像重新縮放後,它會變得非常難看。如何根據iphone屏幕的大小更改圖像?請幫助我
我可以決定兩幅圖像的大小和位置(通過代碼),這取決於iPhone屏幕的尺寸是多少?如果是的話我怎麼會去這樣做呢?
感謝您的幫助新手了!
更新13MAR13
這是我嘗試過的代碼。它不會導致錯誤,但頁面上不會出現圖像!
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
{
CGSize result = [[UIScreen mainScreen] bounds].size;
if(result.height == 480)
{
UIImageView *myImageView = [[UIImageView alloc]initWithFrame: CGRectMake(220, 2.5, 95, 75)];
myImageView.image = [UIImage imageNamed:@"BFS.png"];
UIImageView *myImageViewtwo = [[UIImageView alloc]initWithFrame: CGRectMake(300, 100, 95, 75)];
myImageViewtwo.image = [UIImage imageNamed:@"RMS.png"];
}
if(result.height == 568)
{
UIImageView *myImageView = [[UIImageView alloc]initWithFrame: CGRectMake(100, 400, 95, 75)];
myImageView.image = [UIImage imageNamed:@"BFS.png"];
UIImageView *myImageViewtwo = [[UIImageView alloc]initWithFrame: CGRectMake(100, 300, 95, 75)];
myImageViewtwo.image = [UIImage imageNamed:@"RMS.png"];
}
}
你讀過了嗎? http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/IconsImages/IconsImages.html – tuffkid 2013-03-12 21:19:33
如果您需要根據是iPhone 4還是iPhone 5來更改背景圖片,檢查出http://stackoverflow.com/questions/12446990/how-to-detect-iphone-5-widescreen-devices – Niro 2013-03-12 21:24:21