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]

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM