MyException - 我的异常网
当前位置:我的异常网» Iphone » iphone4 xxx@2.png图片作用和怎么使用

iphone4 xxx@2.png图片作用和怎么使用

www.MyException.Cn  网友分享于:2013-06-30  浏览:14次
iphone4 xxx@2.png图片作用和如何使用

The retinal display on the new iPhone 4 doubles the pixel resolution of the display. However when it comes to laying out the UI elements you can still think about a full screen display with dimensions of 320 x 480 in portrait mode. The big difference is that these dimensions are now expressed in points NOT pixels. What has changed is the scaling factor of the screen which determines how a point relates to a pixel. For the iPhone 4 the display has a scale of 2 so that 1 point = 2 pixels.

The number of pixels on the display has doubled to 640 x 960 but if you are using UIKit this added complexity is mostly hidden from the application. The UI layout is configured using the point dimensions so thankfully you do not have to worry about redoing the layout just for iPhone 4 devices. Also things like text and standard Apple UI components such as navigation bars, system buttons, etc are automatically displayed at the higher pixel resolution. Note that if you are using core graphics or core animation you will have some additional work to do as those frameworks only work with pixels not points.

There are some additional steps that are worth doing if you want your app to look its best on the iPhone 4.

2x Image Files

Apple has introduced a simple naming convention to allow image files at double the resolution to be loaded when the display will support it. To make use of this feature you need to go back to your original image files and create versions at twice the existing size. So if you have an image that is currently 100x100 pixels named myImage.png you need to create a new version which is 200x200 pixels named myImage@2x.png.

You should probably avoid just taking the existing image file and scaling it up to double the size. Ideally you want to create your images at the higher resolution and then scale down to the standard resolution so that both sizes look their best.

Once you have the high-resolution image files you just need to add them to your project and they will be selected automatically anytime you use UIImage class methods such as +imageNamed: or +imageWithContentsOfFile: So for example:

UIImage *myImage = [UIImage imageNamed:@”myImage.png”];

 

will load myImage.png on iPhone 3 and iPad devices but will load myImage@2x.png on the iPhone 4. It is possible to omit the filename extension from the name of the image file with iOS 4 but you will need to include it if you want to maintain compatibility with 3.x releases.

Applications Icons

As well as updating image files you should also update the application icon files to include high-resolution versions of each file. So since the original iPhone application icon file is 57x57 pixels the 2x version needs to be 114x114 pixels. In addition the settings/search icon which is normally 29x29 pixels needs a high-resolution version that is 58x58 pixels.

With iPhone OS 3.2 for the IPad a new key (CFBundleIconFiles) was introduced to Info.plist to specify the ever growing list of icon files. If you are producing an App that will only run only on iOS 4.0 and 3.2 you can use CFBundleIconFiles (you can delete the old CFBundleIconFile key if you want since it will no longer be used).

If you do not specify the filename extensions you can avoid listing all of the 2x variations of the file. So if we have an iPhone icon, an IPad icon and the corresponding settings/search icons the entry in Info.plist would be as follows:

If we want to maintain compatibility with pre-3.2 devices we cannot rely on the CFBundleIconFiles key. Instead we need to specify the icon files using the Apple determined naming convention. The files we would need to support all devices would be as follows:

  • Icon.png - 57x57 pixels application icon for standard resolution iPhone
  • Icon@2x.png - 114x114 pixels application icon for high resolution iPhone 4
  • Icon-72.png - 72x72 pixels application icon for iPad
  • Icon-Small.png - 29x29 pixels settings icon for standard resolution iPhone
  • Icon-Small@2x.png - 58x58 pixels settings icon for high resolution iPhone
  • Icon-Small-50.png - 50x50 pixels settings icon for iPad

Then in the Info.plist file we need to use the original CFBundleIconFile key to specify just the basename of the icon file (“Icon.png”) as follows:

Launch Images

As with the application icons you can also specify high-resolution versions of your launch images. So a standard resolution portrait launch image named Launch.png is 320x480 pixels. The high resolution version would be 640x960 pixels and named Launch@2x.png.

Likewise a landscape version of the file named Default-Landscape.png would be 480x320 in standard resolution (assuming a status bar) and named Default-Landscape@2x.png with 960x640 pixels in high resolution.

文章评论

程序员最害怕的5件事 你中招了吗?
程序员最害怕的5件事 你中招了吗?
程序员必看的十大电影
程序员必看的十大电影
十大编程算法助程序员走上高手之路
十大编程算法助程序员走上高手之路
程序猿的崛起——Growth Hacker
程序猿的崛起——Growth Hacker
代码女神横空出世
代码女神横空出世
亲爱的项目经理,我恨你
亲爱的项目经理,我恨你
程序员和编码员之间的区别
程序员和编码员之间的区别
写给自己也写给你 自己到底该何去何从
写给自己也写给你 自己到底该何去何从
旅行,写作,编程
旅行,写作,编程
程序员应该关注的一些事儿
程序员应该关注的一些事儿
程序员的一天:一寸光阴一寸金
程序员的一天:一寸光阴一寸金
程序员周末都喜欢做什么?
程序员周末都喜欢做什么?
什么才是优秀的用户界面设计
什么才是优秀的用户界面设计
中美印日四国程序员比较
中美印日四国程序员比较
总结2014中国互联网十大段子
总结2014中国互联网十大段子
为啥Android手机总会越用越慢?
为啥Android手机总会越用越慢?
初级 vs 高级开发者 哪个性价比更高?
初级 vs 高级开发者 哪个性价比更高?
聊聊HTTPS和SSL/TLS协议
聊聊HTTPS和SSL/TLS协议
当下全球最炙手可热的八位少年创业者
当下全球最炙手可热的八位少年创业者
Web开发者需具备的8个好习惯
Web开发者需具备的8个好习惯
如何区分一个程序员是“老手“还是“新手“?
如何区分一个程序员是“老手“还是“新手“?
要嫁就嫁程序猿—钱多话少死的早
要嫁就嫁程序猿—钱多话少死的早
老美怎么看待阿里赴美上市
老美怎么看待阿里赴美上市
编程语言是女人
编程语言是女人
我跳槽是因为他们的显示器更大
我跳槽是因为他们的显示器更大
程序员眼里IE浏览器是什么样的
程序员眼里IE浏览器是什么样的
Java程序员必看电影
Java程序员必看电影
程序员都该阅读的书
程序员都该阅读的书
5款最佳正则表达式编辑调试器
5款最佳正则表达式编辑调试器
科技史上最臭名昭著的13大罪犯
科技史上最臭名昭著的13大罪犯
60个开发者不容错过的免费资源库
60个开发者不容错过的免费资源库
做程序猿的老婆应该注意的一些事情
做程序猿的老婆应该注意的一些事情
不懂技术不要对懂技术的人说这很容易实现
不懂技术不要对懂技术的人说这很容易实现
10个调试和排错的小建议
10个调试和排错的小建议
Web开发人员为什么越来越懒了?
Web开发人员为什么越来越懒了?
那些争议最大的编程观点
那些争议最大的编程观点
漫画:程序员的工作
漫画:程序员的工作
如何成为一名黑客
如何成为一名黑客
10个帮程序员减压放松的网站
10个帮程序员减压放松的网站
每天工作4小时的程序员
每天工作4小时的程序员
Java 与 .NET 的平台发展之争
Java 与 .NET 的平台发展之争
 程序员的样子
程序员的样子
我的丈夫是个程序员
我的丈夫是个程序员
程序员的鄙视链
程序员的鄙视链
我是如何打败拖延症的
我是如何打败拖延症的
软件开发程序错误异常ExceptionCopyright © 2009-2015 MyException 版权所有