how to support custom graphics in iPhone 5

删除回忆录丶 提交于 2019-12-05 05:48:28

问题


How to support custom graphics in iPhone 5, 4 inches display.
I know that for Default it's need to add -568h prefix and it's work when my status bar is hidden and my background image size is 640 x 1136 px. But when I need to add custom background for the screen that size smaller then 1136 px it doesn't work.
So how to support custom graphics in new retina display?


回答1:


You can use my three #defines:

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

Just give your images the -568h@2x.png notation, and use iPhone568ImageNamed to get a name for standard name or iPhone 5/new iPod.



来源:https://stackoverflow.com/questions/12516302/how-to-support-custom-graphics-in-iphone-5

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