Specify images for iPad in Xcode like @2x for iPhone 4

前端 未结 2 440
走了就别回头了
走了就别回头了 2020-12-15 23:18

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 th

相关标签:
2条回答
  • 2020-12-15 23:45

    I don't think there's a way to get the OS to pick it automatically for you, like there is for the Retina display. But, you could create a convenience method to return your filenames for you like:

    -(NSString*) myImageFilename:(NSString*)baseName withExtension:(NSString*)ext {
    
     if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
      return [NSString stringWithFormat:"%@@iPadSize.%@"];
     } else {
      return [NSString stringWithFormat:"%@.%@"];
     } 
    
    }
    
    0 讨论(0)
  • 2020-12-15 23:51

    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>
    

    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.

    For more information: http://developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/LoadingResources/Introduction/Introduction.html At "iOS Supports Device-Specific Resources" section.

    0 讨论(0)
提交回复
热议问题