ios IphoneX的一些适配,一些基础宏

1.基本属性

///获取安全区顶部高度
- (CGFloat)getSafeAreaTop{
    if (@available(iOS 11.0, *)) {
        return self.view.safeAreaInsets.top;//44
    } else {
        return 0.0;
    }
}

///获取安全区底部高度
- (CGFloat)getSafeAreaBottom{
    if (@available(iOS 11.0, *)) {
        return self.view.safeAreaInsets.bottom;//34
    } else {
        return 0.0;
    }
}

///获取window安全区底部高度
- (CGFloat)getWindowSafeAreaBottom{
    if (@available(iOS 11.0, *)) {
        return [UIApplication sharedApplication].delegate.window.safeAreaInsets.bottom;//34
    }
    return 0.0;
}

///获取window安全区顶部高度
- (CGFloat)getWindowSafeAreaTop{
    if (@available(iOS 11.0, *)) {
        return [UIApplication sharedApplication].delegate.window.safeAreaInsets.top;//44
    }
    return 0.0;
}

2.一些基础宏

#define IphoneX [[DeviceDataLibrery sharedLibrery] isIphoneX]

#define UIColorFromRGBA(rgbValue, alphaValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0x00FF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0x0000FF))/255.0 \
alpha:alphaValue]
#define UIColorFromRGB(rgbValue)              UIColorFromRGBA(rgbValue, 1.0)

#define UIScreenWidth               ([UIScreen mainScreen].bounds.size.width)
#define UIScreenHeight              ([UIScreen mainScreen].bounds.size.height)

// MARK: 系统宏定义
#define IOS11           ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 11.0)
#define IOS10           ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 10.0)
#define IOS9            ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 9.0)
#define IOS8            ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 8.0)
#define IOS8_2          ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 8.2)
#define IOS7            ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 7.0)
#define IOS7_1          ([[[UIDevice currentDevice] systemVersion] doubleValue] >= 7.1)

// 是否是模拟器
#define isSimulator     ([DeviceUtil hardware] == SIMULATOR)

#define ProjectTitle    @"应用名字"

#define AccessPhoto [NSString stringWithFormat:@"请在iPhone的\"设置-隐私-照片\"选项中,允许%@访问您的照片",ProjectTitle]
#define AccessCamera [NSString stringWithFormat:@"请在iPhone的\"设置-隐私-相机\"选项中,允许%@访问您的相机",ProjectTitle]
#define AccessLocation [NSString stringWithFormat:@"请在iPhone的\"设置-隐私-定位服务\"选项中,允许%@获取您的地理位置",ProjectTitle]
#define AccessMicrophone [NSString stringWithFormat:@"请在iPhone的\"设置-隐私-麦克风\"选项中,允许%@使用您的麦克风",ProjectTitle]

#define NormalTeamErrorTip [NSString stringWithFormat:@"****%@不支持普通群****",ProjectTitle]
#define FileTransferTip [NSString stringWithFormat:@"在这里可以将照片、文件发送到电脑端%@",ProjectTitle]

 

转载于:https://www.cnblogs.com/qiyiyifan/p/8308584.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值