美文网首页
ios通用宏定义,含iphone X及以上适配宏

ios通用宏定义,含iphone X及以上适配宏

作者: Peter_song | 来源:发表于2019-09-26 16:12 被阅读0次

/** RGB颜色 **/

#define RGBColor(r, g, b) [UIColor colorWithRed:(r)/255.0green:(g)/255.0blue:(b)/255.0alpha:1.0]

/** 屏幕的宽度 **/

#define MainScreenWidth ([UIScreen mainScreen].bounds.size.width)

/** 屏幕的高度 **/

#define MainScreenHeight ([UIScreen mainScreen].bounds.size.height)

/** 判读是否为iPhone X及以上 **/

#define IPHONE_X \

({BOOL isPhoneX = NO;\

if (@available(iOS11.0, *)) {\

isPhoneX = [[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom >0.0;\

}\

(isPhoneX);})

/** 宽度倍率 **/

#define MLWidthScale  mainScreenWidth/375

/** 高度的倍率 **/

#define MLHeightScale mainScreenHeight/667

/** 导航栏高度 **/

#define NavigationbarHeight ((self.navigationController.navigationBar.frame.size.height))

/** 状态栏高度 **/

#define StatusbarHeight (IPHONE_X ?44:20)

/** 状态栏加导航栏高度 **/

#define StatusbarAndNavigationbarHeight (IPHONE_X ?88:64)

/** tabbar高度 **/

#define TabBarHeight (IPHONE_X ? (49.f+34.f) :49.f)

/** 底部安全区域 **/

#define SafeAreaBottom (IPHONE_X ?34:0)

/** 服务器地址 **/

#define SERVERURL @"http://xxx.xxx.com"

后续还会补充,持续更新...

相关文章

网友评论

      本文标题:ios通用宏定义,含iphone X及以上适配宏

      本文链接:https://www.haomeiwen.com/subject/xppxuctx.html