`
yourgame
  • 浏览: 352596 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

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

    博客分类:
  • IOS
阅读更多
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)];
    }
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics