zoukankan      html  css  js  c++  java
  • 如何让自己的程序支持iPhone5–RetinaImages

    我们知道如果想让程序的启动图像能够适应iPhone5(640X1136),那么我们需要把启动的图像命名以“-568h@2x”结尾的图片,那 么是不是程序中用到的所有图片都可以用这样的方式来命名,以适合iPhone5呢,事实并不是这样的,这里需要我们自己来做一下调整。

    我们来写一个UIImage的扩展方法

    UIImage+iPhone5extension.h

    1. #import <UIKit/UIKit.h> @interface UIImage (iPhone5extension)
    2. +(UIImage*)imageNamedForDevice:(NSString*)name;
    3. @end

    UIImage+iPhone5extension.m

    1. #import "UIImage+iPhone5extension.h"
    2.  
    3. @implementationUIImage(iPhone5extension)
    4.  
    5. +(UIImage*)imageNamedForDevice:(NSString*)name {
    6.  
    7.  UIImage*returnImage =[UIImage imageNamed:[NSString stringWithFormat:@"%@", name]];
    8. if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone)
    9.  {
    10. if(([UIScreenmainScreen].bounds.size.height *[UIScreenmainScreen].scale)>=1136)
    11.  {
    12.  return[UIImage imageNamed:[NSString stringWithFormat:@"%@-568h@2x", name]];
    13.  }
    14.  }
    15.  
    16.  return returnImage;
    17. }
    18.  
    19. @end
  • 相关阅读:
    【iOS
    【iOS】Swift ESTabBarController的使用
    【iOS
    【iOS】图表实现-Charts(二)
    【iOS】图表实现-Charts(一)
    【iOS】图表实现-AAChartKit
    【iOS】图表实现-总述
    【iOS
    【iOS
    整理下开发中常用的第三方库
  • 原文地址:https://www.cnblogs.com/lisa090818/p/3238578.html
Copyright © 2011-2022 走看看