自己常用的一些宏定義 可以拿去直接用的茅撞, 自己保存記錄一下
//導(dǎo)航
#define kStatusBarHeight [[UIApplication sharedApplication] statusBarFrame].size.height
#define kNavBarHeight44.0
#define kTabBarHeight (iPhoneX?83:49)
#define kTopHeight (kStatusBarHeight + kNavBarHeight)
#define KIPhoneXSafeHeight (iPhoneX?34:0)
#define KIPhoneXBottomSafeHeight (iPhoneX?44:0)
#define KIPhoneXTotalSafeHeight (iPhoneX?78:0)
//是否為空
#define IsNilOrNull(_ref)? (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]))
//字符串是否為空
#define IsStrEmpty(_ref)? ? (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]) ||([_ref isKindOfClass:[NSString class]] &&[(_ref)isEqualToString:@""]) || ([_ref isKindOfClass:[NSString class]] && [(_ref) isEqualToString:@"(null)"]))
//數(shù)組是否為空
#define IsArrEmpty(_ref)? ? (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]) ||([_ref isKindOfClass:[NSArray class]]&&[(_ref) count] ==0))
//16進(jìn)制色值參數(shù)轉(zhuǎn)換
#define COLOR_0X(RGB) [UIColor colorWithRed:((float)((RGB &0xFF0000) >>16)) /255.0\
green:((float)((RGB &0xFF00) >>8)) /255.0\
blue:((float)((RGB &0xFF))) /255.0\
alpha:1.0]
//RGB顏色轉(zhuǎn)換
#define RGBA(r,g,b,p) [UIColor colorWithRed:(CGFloat)(r)/255.0green:(CGFloat)(g)/255.0blue:(CGFloat)(b)/255.0alpha:p]
//單例創(chuàng)建
#undef AS_SINGLETON
#define AS_SINGLETON( __class ) \
+ (__class *)sharedInstance;
#undef DEF_SINGLETON
#define DEF_SINGLETON( __class ) \
+ (__class *)sharedInstance \
{ \
static dispatch_once_t once; \
static __class * __singleton__; \
dispatch_once( &once, ^{ __singleton__ = [[__class alloc] init]; } ); \
return __singleton__; \
}
// 隨機(jī)色
#define YKRandomColor YKColor(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))
// 透明顏色
#define YKAlphaColor(r, g, b, a) [UIColor colorWithRed:(r)/255.0green:(g)/255.0blue:(b)/255.0alpha:(a)/10.0]
//提示框
#define ShowMessage(TITLE,MESSAGE,QUVC) UIAlertController *alertController = [UIAlertController alertControllerWithTitle:TITLE message:MESSAGE preferredStyle:UIAlertControllerStyleAlert];\
[alertController addAction:[UIAlertAction actionWithTitle:@"確定"style:UIAlertActionStyleDefault handler:nil]];\
[QUVC presentViewController:alertController animated:YES completion:nil];