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
  • 相关阅读:
    CoreBluetooth
    弹出照片选择器
    ios 去除UITextField中的空格
    ios UITableView默认选中第一行
    ios 监听设备旋转方向
    ios 添加朦层
    ios 异步加载图片
    ios 屏幕旋转的问题
    c# Socket通信基础
    ios 更改全局UINavigationBar的背景图片以及通知栏颜色
  • 原文地址:https://www.cnblogs.com/lisa090818/p/3238578.html
Copyright © 2011-2022 走看看