美文网首页
ios宏的简单实用

ios宏的简单实用

作者: 我是啊梁 | 来源:发表于2018-09-30 10:26 被阅读0次

// 懒加载

#define HT_LAZY(object, assignment) (object = object ?: assignment)

// 返回一个字符串

#define stringify  __STRING

// 设置颜色

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

#define SetAColor(r, g, b, a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]

// 设置字体

#define SetFont(fontName,font)    [UIFont fontWithName:(fontName) size:(font)]

// 获取屏幕宽度,高度

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

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

// 判断是否是X系列

#define IS_IPHONEX \

({\

    BOOL iPhoneXSeries = NO;\

    if (UIDevice.currentDevice.userInterfaceIdiom != UIUserInterfaceIdiomPhone) { \

      (iPhoneXSeries); \

    }  \

    if (@available(iOS 11.0, *)) { \

        UIWindow *mainWindow = [[[UIApplication sharedApplication] delegate] window]; \

        if (mainWindow.safeAreaInsets.bottom > 0.0) { \

            iPhoneXSeries = YES; \

        } \

    } \

    (iPhoneXSeries); \

}) \

#define Height (IS_IPHONEX ? ([[UIScreen mainScreen] bounds].size.height-20):([[UIScreen mainScreen] bounds].size.height))

//判断编译环境

#if DEBUG

#define kBaseImageURL @""

#else

#define kBaseImageURL @""

#endif

相关文章

网友评论

      本文标题:ios宏的简单实用

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