Xcode 4.5 different iPhone backgroud on iPhone 4s and 5

心不动则不痛 提交于 2020-03-05 03:06:23

问题


I have made two different background images for my iPhone app: one in 640x960px (iPhone4s) and one in 640x1136px (iPhone5). But when I create the application layouts in the Xcode 4.5 Main Storyboard, how do I define and create it for both iPhone4s and iPhone5? So that the background automatically updates when i choose iPhone5 screen?


回答1:


Just import your background image with the correct suffix

For example :

myImage.png for non-retina display

myImage@2x.png for retina display

myImage-568h@2x.png for iPhone 5




回答2:


In your viewController set:

self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"image.jpg"]];

Remember to correctly named the image:

  • for iphone4 "image@2x.png"
  • for iphone5 "image-568h@2x.png"


来源:https://stackoverflow.com/questions/13055007/xcode-4-5-different-iphone-backgroud-on-iphone-4s-and-5

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!