判断iOS设备的尺寸

来源:互联网 发布:centos 6.5网络配置ip 编辑:程序博客网 时间:2024/05/22 14:02

UIDevice + TL

#import <UIKit/UIKit.h>

typedef NS_ENUM(NSInteger, DeviceVerType){
    DeviceVer4,
    DeviceVer5,
    DeviceVer6,
    DeviceVer6P,
};

@interface UIDevice (TL)

+ (DeviceVerType)deviceVerType;

@end


#import "UIDevice+TL.h"

#define WIDTH_SCREEN        [UIScreen mainScreen].bounds.size.width
#define HEIGHT_SCREEN       [UIScreen mainScreen].bounds.size.height

@implementation UIDevice (TL)

+ (DeviceVerType)deviceVerType{
    if (WIDTH_SCREEN == 375) {
        return DeviceVer6;
    }else if (WIDTH_SCREEN == 414){
        return DeviceVer6P;
    }else if(HEIGHT_SCREEN == 480){
        return DeviceVer4;
    }else if (HEIGHT_SCREEN == 568){
        return DeviceVer5;
    }
    return DeviceVer4;
}

@end




0 0
原创粉丝点击