在Xcode中为iPad指定图像,如iPhone 2的@ 2x [英] Specify images for iPad in Xcode like @2x for iPhone 4
问题描述
我已将当前目标升级到iPad并制作了一个通用应用程序,如果有这个问题的答案,调整我的iphone应用程序到ipad的时间会大大减少。
I have upgraded my current target to iPad and made a universal app and the time for adjusting my iphone app to ipad would decrease significantly if there is an answer for this question.
此时每个人都知道,如果你有一个名为 football.png 的图片,并希望支持Retina Display,你应该将图像的大小加倍并称之为 football @ 2x.png 。
By this time everybody know that if you have a image called "football.png" and want support for Retina Display you should double the size of the image and call it "football@2x.png".
我的问题是iPad上是否有像* football@iPad_which_is_another_size.png *?
My question is if there is something for iPad like *football@iPad_which_is_another_size.png*?
如果没有办法做到这一点,我是否必须将每个图像连接到IBOutlet并以编程方式设置框架?
If there isn't a way to do this, do I have to connect every image to an IBOutlet and set the frame programmatically?
推荐答案
在iOS 4.0及更高版本中,可能
将单个资源文件标记为
仅可用于特定类型的
device
要将资源文件与
特定设备相关联,请在其文件名中添加自定义
修饰符字符串。包含此修饰符字符串
的
产生具有以下
格式的文件名:
In iOS 4.0 and later, it is possible to mark individual resource files as usable only on a specific type of device To associate a resource file with a particular device, you add a custom modifier string to its filename. The inclusion of this modifier string yields filenames with the following format:
<basename><device>.<filename_extension>
要加载iPad特定资源,您应该使用 ~ipad
。示例:创建名为 AwesomeImage~ipad.png
的图像,并加载 [UIImage imageNamed:@AwesomeImage.png]
就像你做视网膜显示图像一样。
To load the iPad specific resources you should use ~ipad
. Example: create the image named AwesomeImage~ipad.png
and load with [UIImage imageNamed:@"AwesomeImage.png"]
like you do for retina display image.
更多信息: http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/LoadingResources/Introduction/Introduction.html
在iOS支持设备特定资源部分。
For more information: http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/LoadingResources/Introduction/Introduction.html At "iOS Supports Device-Specific Resources" section.
这篇关于在Xcode中为iPad指定图像,如iPhone 2的@ 2x的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!