当前位置: 代码迷 >> Iphone >> 经过代码判断iphone 4的Retina屏幕分辨率
  详细解决方案

经过代码判断iphone 4的Retina屏幕分辨率

热度:44   发布时间:2016-04-25 06:25:32.0
通过代码判断iphone 4的Retina屏幕分辨率
iPhone 4 发布以来,开发者面临的一大问题就是软件要适应2种分辨率的屏幕。以下这段代码能判断当前运行的设备是否是 iPhone 4 的 Retina 屏,以便做出图标加载等调整。

//在头上门定义#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)//方法中可以实用- (void)loadView{if (isRetina) {        chkUserName = [[UIButton alloc]initWithFrame:CGRectMake(chkUserNameLeft, top,bigWidth,bigHeight)];    }else{        chkUserName = [[UIButton alloc]initWithFrame:CGRectMake(chkUserNameLeft, top,smallWidth,smallHeight)];    }}
  相关解决方案