• <small id='wuXfn'></small><noframes id='wuXfn'>

    • <bdo id='wuXfn'></bdo><ul id='wuXfn'></ul>
    <legend id='wuXfn'><style id='wuXfn'><dir id='wuXfn'><q id='wuXfn'></q></dir></style></legend>

      <tfoot id='wuXfn'></tfoot>

      1. <i id='wuXfn'><tr id='wuXfn'><dt id='wuXfn'><q id='wuXfn'><span id='wuXfn'><b id='wuXfn'><form id='wuXfn'><ins id='wuXfn'></ins><ul id='wuXfn'></ul><sub id='wuXfn'></sub></form><legend id='wuXfn'></legend><bdo id='wuXfn'><pre id='wuXfn'><center id='wuXfn'></center></pre></bdo></b><th id='wuXfn'></th></span></q></dt></tr></i><div id='wuXfn'><tfoot id='wuXfn'></tfoot><dl id='wuXfn'><fieldset id='wuXfn'></fieldset></dl></div>
      2. iOS 图像命名约定

        时间:2024-04-14

          <tbody id='7TynZ'></tbody>
        • <bdo id='7TynZ'></bdo><ul id='7TynZ'></ul>
              <tfoot id='7TynZ'></tfoot>
            • <small id='7TynZ'></small><noframes id='7TynZ'>

              <i id='7TynZ'><tr id='7TynZ'><dt id='7TynZ'><q id='7TynZ'><span id='7TynZ'><b id='7TynZ'><form id='7TynZ'><ins id='7TynZ'></ins><ul id='7TynZ'></ul><sub id='7TynZ'></sub></form><legend id='7TynZ'></legend><bdo id='7TynZ'><pre id='7TynZ'><center id='7TynZ'></center></pre></bdo></b><th id='7TynZ'></th></span></q></dt></tr></i><div id='7TynZ'><tfoot id='7TynZ'></tfoot><dl id='7TynZ'><fieldset id='7TynZ'></fieldset></dl></div>
                  <legend id='7TynZ'><style id='7TynZ'><dir id='7TynZ'><q id='7TynZ'></q></dir></style></legend>
                  本文介绍了iOS 图像命名约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  I'm relatively new in iOS development.

                  I'm currently building an app using the cocos2d library that will be available for the iPad Retina, iPad, iPhone 5, and iPhone 4s/4.

                  I'm getting all of my images setup, and I'm trying to figure out the naming conventions.

                  Does anyone know of a guide out there that could help me?

                  Say I have a background.png.

                  From what I understand:

                  • background.png -> iPhone (non-retina/fallback)
                  • background-hd.png -> iPhone 4s/4 (retina)
                  • background-ipad.png -> iPad (non-retina)
                  • background-ipadhd.png -> iPad (retina)

                  And the same naming convention would be used for all other files? For example:

                  • arbitraryButton.png -> iPhone (non-retina/fallback)
                  • arbitraryButton-hd.png -> iPhone 4s/4 (retina)
                  • arbitraryButton-ipad.png -> iPad (non-retina)
                  • arbitraryButton-ipadhd.png -> iPad (retina)

                  What do I name the iPhone 5 files?

                  I've searched a bit and cant seem to find any tangible guides out there on this.

                  Thank you!

                  解决方案

                  The OS has a naming convention that you can use (and enforces for you, meaning you only need to reference the file as @"fileName"). The documentation is available here.

                  • fileName.png -> iPhone (non-retina/fallback)
                  • fileName@2x.png -> iPhone 4s/4 (retina)
                  • fileName~ipad.png -> iPad (non-retina)
                  • fileName@2x~ipad.png -> iPad (retina)

                  Note: ~iphone also exists, and can be used with/instead of using ~ipad. Using both ~ipad and ~iphone would safeguard against a third idiom Apple may introduce. cough TV cough

                  As for the iPhone 5, the OS does not enforce a naming scheme. But, it'd probably be wise to use the same scheme as that for the launch image.

                  • fileName-568h@2x.png -> iPhone 5

                  To handle this easily throughout the app, you can create a category, and use it where you know you will have an iPhone 5 friendly image, as well as a regular sized image. A simple version can be made, like the one below.

                  UIImage+iPhone5Image.h

                  #import <UIKit/UIKit.h>
                  
                  @interface UIImage (iPhone5Image)
                  
                  + (UIImage*)iPhone5ImageNamed:(NSString*)imageName;
                  
                  @end
                  

                  UIImage+iPhone5Image.m

                  #import "UIImage+iPhone5Image.h"
                  
                  #define IsIPhone5() ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 568)
                  
                  @implementation UIImage (iPhone5Image)
                  
                  + (UIImage*)iPhone5ImageNamed:(NSString*)imageName
                  {
                      if (IsIPhone5()) {
                          NSString* newImageName = [NSString stringWithFormat:@"%@-568h", imageName];
                          return [UIImage imageNamed:newImageName];
                      }
                      else {
                          return [UIImage imageNamed:imageName];
                      }
                  }
                  
                  @end
                  

                  这篇关于iOS 图像命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在cocos2d中检测精灵上的透明部分? 下一篇:在 AppDelegate 中调用函数?

                  相关文章

                    <small id='6cdfb'></small><noframes id='6cdfb'>

                      <i id='6cdfb'><tr id='6cdfb'><dt id='6cdfb'><q id='6cdfb'><span id='6cdfb'><b id='6cdfb'><form id='6cdfb'><ins id='6cdfb'></ins><ul id='6cdfb'></ul><sub id='6cdfb'></sub></form><legend id='6cdfb'></legend><bdo id='6cdfb'><pre id='6cdfb'><center id='6cdfb'></center></pre></bdo></b><th id='6cdfb'></th></span></q></dt></tr></i><div id='6cdfb'><tfoot id='6cdfb'></tfoot><dl id='6cdfb'><fieldset id='6cdfb'></fieldset></dl></div>
                    1. <legend id='6cdfb'><style id='6cdfb'><dir id='6cdfb'><q id='6cdfb'></q></dir></style></legend>
                        <bdo id='6cdfb'></bdo><ul id='6cdfb'></ul>
                    2. <tfoot id='6cdfb'></tfoot>