zoukankan      html  css  js  c++  java
  • IOS 判断设备屏幕尺寸、分辨率

    根据屏幕尺寸和分辨率,ios现在数起来有6个版本。
    
    iOS 设备现有的分辨率如下:
    iPhone/iPod Touch
    普通屏                           320像素 x 480像素       iPhone 1、3G、3GS,iPod Touch 123
    32 Retina 屏             640像素 x 960像素        iPhone 4、4S,iPod Touch 4
    169 Retina 屏               640像素 x 1136像素      iPhone 5,iPod Touch 5
    
    iPad
    普通屏                  768像素 x 1024像素      iPad 1, iPad2,iPad mini
    Retina屏                  1536像素 x 2048像素     New iPad,iPad 4
    
     
    
    UIDevice+Resolutions.h
    
     
    
    //
    //  UIDevice+Resolutions.h
    //  Test_common
    //
    //  Created by wangzhipeng on 13-1-30.
    //  Copyright (c) 2013年 com.comsoft. All rights reserved.
    //
    
    #import 
    
    enum {
        // iPhone 1,3,3GS 标准分辨率(320x480px)
        UIDevice_iPhoneStandardRes      = 1,
        // iPhone 4,4S 高清分辨率(640x960px)
        UIDevice_iPhoneHiRes            = 2,
        // iPhone 5 高清分辨率(640x1136px)
        UIDevice_iPhoneTallerHiRes      = 3,    
        // iPad 1,2 标准分辨率(1024x768px)
        UIDevice_iPadStandardRes        = 4,    
        // iPad 3 High Resolution(2048x1536px)
        UIDevice_iPadHiRes              = 5               
    }; typedef NSUInteger UIDeviceResolution;
    
    @interface UIDevice (Resolutions){
        
    }
    
    
    + (UIDeviceResolution) currentResolution;
    
    
    + (BOOL)isRunningOniPhone5;
    
    
    + (BOOL)isRunningOniPhone;
    
    @end
     
     
    
    UIDevice+Resolutions.m
    
     
    
    //
    //  UIDevice+Resolutions.m
    //  Test_common
    //
    //  Created by wangzhipeng on 13-1-30.
    //  Copyright (c) 2013年 com.comsoft. All rights reserved.
    //
    
    #import "UIDevice+Resolutions.h"
    
    @implementation UIDevice (Resolutions)
    
    
    + (UIDeviceResolution) currentResolution {
        if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
            if ([[UIScreen mainScreen] respondsToSelector: @selector(scale)]) {
                CGSize result = [[UIScreen mainScreen] bounds].size;
                result = CGSizeMake(result.width * [UIScreen mainScreen].scale, result.height * [UIScreen mainScreen].scale);
                if (result.height <= 480.0f)
                    return UIDevice_iPhoneStandardRes;
                return (result.height > 960 ? UIDevice_iPhoneTallerHiRes : UIDevice_iPhoneHiRes);
            } else
                return UIDevice_iPhoneStandardRes;
        } else
            return (([[UIScreen mainScreen] respondsToSelector: @selector(scale)]) ? UIDevice_iPadHiRes : UIDevice_iPadStandardRes);
    }
    
    
    + (BOOL)isRunningOniPhone5{
        if ([self currentResolution] == UIDevice_iPhoneTallerHiRes) {
            return YES;
        }
        return NO;
    }
    
    
    + (BOOL)isRunningOniPhone{
        return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone);
    }
    
    @end
  • 相关阅读:
    Linux input子系统学习总结(一)---- 三个重要的结构体
    DRM/KMS 基本组件介绍
    Framebuffer 驱动学习总结(二)---- Framebuffer模块初始化
    Framebuffer 驱动学习总结(一) ---- 总体架构及关键结构体
    Linux USB驱动学习总结(三)---- USB鼠标的加载、初始化和通信过程
    Linux USB驱动学习总结(一)---- USB基本概念及驱动架构
    使用Python调用动态库
    使用 SignalR与SSE(Sever sent event)向客户端推送提示信息
    在IDEA下使用Spring Boot的热加载(Hotswap)
    使用Spring boot + jQuery上传文件(kotlin)
  • 原文地址:https://www.cnblogs.com/jiackyan/p/3210115.html
Copyright © 2011-2022 走看看