Use @2x retina images for ipad in universal app? and does apple prefer native apps?

后端 未结 4 816
梦如初夏
梦如初夏 2020-12-23 15:27

I know there were some discussions about this but i could not find good answer?

My questions are -

  1. I know that -

      [UIImage imageNam         
    
    
            
4条回答
  •  失恋的感觉
    2020-12-23 16:05

    There is no good built-in way of not duplicating the higher res iphone retina images for the iPad. You could write your own UIImage extension or subclass that uses the user interface idiom macro to determine your platform, then automatically append "@2x" to the image name:

    + (UIImage *) imageNamedSmart:(NSString *)name
    {
        if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad )
            return [UIImage imageNamed:[NSString stringWithFormat:@"%@@2x.png", name]];
        return [UIImage imageNamed:[NSString stringWithFormat:@"%@.png", name]];
    }
    

    and you'd call it like this:

    [UIImage imageNamedSmart:@"myImage"]
    

提交回复
热议问题