NLog处理
- 设置Build Setings -> Preprocessor Mecros -> Debug DEBUG=1 Build
Build Setings -> Preprocessor Mecros -> Release
#pragma mark - NSLog在release下不输出
#ifdef DEBUG
#define NSLog(formater,...) NSLog((@"\n[文件名:%s] " "函数名:%s\n" "代码行数: %d " formater),[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String],__PRETTY_FUNCTION__,__LINE__,##__VA_ARGS__)
#else
#define NSLog(...)
#endif
#define MyLog(format, ...) printf("文件名: <%s 代码行数:(%d) >\n函数名: %s \n%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String] )
weakself设置
#define AAWeakSelf(type) autoreleasepool{} __weak typeof(type) weak##type = type;
#define AAStrongSelf(type) autoreleasepool{} __strong typeof(type) type = weak##type;
#define kWeakSelf(type) @AAWeakSelf(type);
#define kStrongSelf(type) @AAStrongSelf(type);
常用宽高
#pragma mark - 常用宽高
#define kWidth ([UIScreen mainScreen].bounds.size.width)
#define kHeight ([UIScreen mainScreen].bounds.size.height)
#define kStatusBarHeight ([[UIApplication sharedApplication] statusBarFrame].size.height > 20 ? 44.0 : 20.0)
#define kNavBarHeight ([[UIApplication sharedApplication] statusBarFrame].size.height > 20 ? 88.0 : 64.0)
#define kTabBarHeight ([[UIApplication sharedApplication] statusBarFrame].size.height > 20 ? 83.0 : 49.0)
#define kTabBarBottom ([[UIApplication sharedApplication] statusBarFrame].size.height > 20 ? 34.0 : 0)
文字字体
#pragma mark - 文字字体
#define kFontSys_UltraLight(s) [UIFont systemFontOfSize:s weight:UIFontWeightUltraLight]
#define kFontSys_Thin(s) [UIFont systemFontOfSize:s weight:UIFontWeightThin]
#define kFontSys_Light(s) [UIFont systemFontOfSize:s weight:UIFontWeightLight]
#define kFontSys_Regular(s) [UIFont systemFontOfSize:s weight:UIFontWeightRegular]
#define kFontSys_Medium(s) [UIFont systemFontOfSize:s weight:UIFontWeightMedium]
#define kFontSys_Semibold(s) [UIFont systemFontOfSize:s weight:UIFontWeightSemibold]
#define kFontSys_Bold(s) [UIFont systemFontOfSize:s weight:UIFontWeightBold]
#define kFontSys_Heavy(s) [UIFont systemFontOfSize:s weight:UIFontWeightHeavy]
#define kFontSys_Black(s) [UIFont systemFontOfSize:s weight:UIFontWeightBlack]
#define kFontName(name,s) [UIFont fontWithName:name size:s]
#define kFontWeight(w,s) [UIFont monospacedDigitSystemFontOfSize:s weight:w]
取色值相关的方法
#pragma mark - 取色值相关的方法
#define kRamdomColor [UIColor colorWithRed:(arc4random() % 256)/255.0 green:(arc4random() % 256)/255.0 blue:(arc4random() % 256)/255.0 alpha:1]
#define kRGB(r,g,b) [UIColor colorWithRed:(r)/255.f \
green:(g)/255.f \
blue:(b)/255.f \
alpha:1.f]
#define kRGBW(w) [UIColor colorWithRed:(w)/255.f \
green:(w)/255.f \
blue:(w)/255.f \
alpha:1.f]
#define kRGBA(r,g,b,a) [UIColor colorWithRed:(r)/255.f \
green:(g)/255.f \
blue:(b)/255.f \
alpha:(a)]
#define kRGB_OF(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 kRGBA_OF(rgbValue) [UIColor colorWithRed:((float)(((rgbValue) & 0xFF000000) >> 24))/255.0 \
green:((float)(((rgbValue) & 0x00FF0000) >> 16))/255.0 \
blue:((float)(rgbValue & 0x0000FF00) >> 8)/255.0 \
alpha:((float)(rgbValue & 0x000000FF))/255.0]
#define kRGBAOF(v, a) [UIColor colorWithRed:((float)(((v) & 0xFF0000) >> 16))/255.0 \
green:((float)(((v) & 0x00FF00) >> 8))/255.0 \
blue:((float)(v & 0x0000FF))/255.0 \
alpha:a]
通知消息
#define kNotificationCenter [NSNotificationCenter defaultCenter]
#define kPost_Notify(_notificationName, _obj, _userInfoDictionary) [[NSNotificationCenter defaultCenter] postNotificationName: _notificationName object: _obj userInfo: _userInfoDictionary];
#define kAdd_Observer(_observer, _notificationName, _observerSelector, _obj) [[NSNotificationCenter defaultCenter] addObserver:_observer selector:@selector(_observerSelector) name:_notificationName object: _obj];
#define kRemove_Observer(_observer) [[NSNotificationCenter defaultCenter] removeObserver: _observer];