美文网首页
iOS开发中常用宏

iOS开发中常用宏

作者: 落寞绅士 | 来源:发表于2022-06-06 09:29 被阅读0次
#define SCREEN_HEIGHT   [UIScreen mainScreen].bounds.size.height
#define SCREEN_WIDTH    [UIScreen mainScreen].bounds.size.width
#define SCREEN_SCORE    ([UIScreen mainScreen].bounds.size.width / 320.f)
#define WEAK_SELF       typeof(self) __weak weakSelf = self;
#define STRONG_SELF     typeof(weakSelf) __strong strongSelf = weakSelf;

// corlor
#define RGB(r, g, b)                 [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]
#define RGBA(r, g, b, a)             [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)]
#define UIColorFromHEX(rgbValue)     [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define UIColorFromHEXA(rgbValue,a)  [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:a]
// device
#define IS_IPHONE    (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_PAD       (UI_USER_INTERFACE_IDIOM()== UIUserInterfaceIdiomPad)
#define kAPPDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate])

//异性全面屏
#define kIsFullScreen ({\
BOOL isBangsScreen = NO; \
if (@available(iOS 11.0, *)) { \
UIWindow *window = [[UIApplication sharedApplication].windows firstObject]; \
isBangsScreen = window.safeAreaInsets.bottom > 0; \
} \
isBangsScreen; \
})
// Status bar height.
#define kStatusBarHeight (kIsFullScreen ? 44.f : 20.f)
// Navigation bar height.
#define kNavigationBarHeight 44.f
// Tabbar height.
#define kTabbarHeight (kIsFullScreen ? (49.f+34.f) : 49.f)
// Tabbar safe bottom margin.
#define kTabbarSafeBottomMargin (kIsFullScreen ? 34.f : 0.f)
// Status bar & navigation bar height.
#define kStatusBarAndNavigationBarHeight (kIsFullScreen ? 88.f : 64.f)

// debug log
#ifdef DEBUG
#   define DLog(format, ...) printf("class: <%p %s:(%d) > method: %s \n%s\n", self, [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String] );
#else
#   define DLog(...)
#endif

相关文章

  • iOS开发中常用的宏

    以下为iOS开发中常用宏: 引用:ios开发常用的宏,大家一起来收集 参考:ios开发常用的宏,大家一起来收集~

  • iOS 开发小经验

    iOS 开发中你是否遇到这些经验问题(一)iOS 开发中你是否遇到这些经验问题(二)iOS 日常工作之常用宏定义大全

  • iOS开发中常用到的宏

    大家都是知道使用宏不仅方便,而且可以提高开发效率。下面总结了iOS开发过程中的一些常用宏。

  • iOS开发常用的工具类和宏定义

    iOS开发常用的工具类和宏定义 开发总结的工具类和宏 https://github.com/xiaoChen66...

  • iOS 常用宏定义

    iOS 开发中使用一些常用宏定义可以大大提高开发效率,提高代码的重用性.以下是一些常用的宏定义: 像这些宏定义,在...

  • iOS 开发常用宏

    大家都是知道使用宏不仅方便,而且可以提高开发效率。下面总结了iOS开发过程中的一些常用宏,会持续的往里面添加。 /...

  • iOS 开发中 runtime 常用的几种方法

    iOS 开发中 runtime 常用的几种方法 iOS 开发中 runtime 常用的几种方法

  • iOS 宏(define)与常量(const)的正确使用

    在iOS开发中,经常用到宏定义,或用const修饰一些数据类型,经常有开发者不知怎么正确使用,导致项目中乱用宏与c...

  • iOS开发常用宏,持续更新中

    大家都是知道使用宏不仅方便,而且可以提高开发效率。下面总结了iOS开发过程中的一些常用宏,会持续的往里面添加。 持...

  • define 和 const常量有什么区别?

    在iOS开发中,经常用到宏定义,或用const修饰一些数据类型,经常有开发者不知怎么正确使用,导致项目中乱用宏与c...

网友评论

      本文标题:iOS开发中常用宏

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