// // Prefix header // // The contents of this file are implicitly included at the beginning of every source file. // #import #ifndef __IPHONE_3_0 #warning "This project uses features only available in iOS SDK 3.0 and later." #endif #ifdef __OBJC__ #import #import #import #import "NSString+Common.h" #import "NSObject+Common.h" #import "UIImage+Common.h" #import "UIButton+Bootstrap.h" #import "UIColor+expanded.h" #import "UIButton+Common.h" #import "UITableView+Common.h" #import "UIView+Common.h" #import "UILabel+Common.h" #import "NSDate+Common.h" #import "UIBarButtonItem+Common.h" #import "NSURL+Common.h" #import "UISearchBar+Common.h" #import "UITTTAttributedLabel.h" #import "NSObject+ObjectMap.h" #import "ImageSizeManager.h" #import #import #import #import #import "UIImageView+WebCache.h" #import #import "UIView+SDAutoLayout.h" #import "UITableView+SDAutoTableViewCellHeight.h" #import "PHAsset+Common.h" #import "UINavigationBar+Common.h" #import "BaseNavigationController.h" #import "BaseViewController.h" #endif #define SD_WEBP //友盟统计 #define kUmeng_AppKey @"" #define kUmeng_Event_Request_Notification @"Request_Notification" #define kUmeng_Event_Request_RootList @"Request_RootList" #define kUmeng_Event_Request_Get @"Request_Get" #define kUmeng_Event_Request_ActionOfServer @"Request_ActionOfServer" #define kUmeng_Event_Request_ActionOfLocal @"Request_ActionOfLocal" //Social Data #define kSocial_WX_ID @"" #define kSocial_WX_Secret @"" #define kSocial_QQ_ID @"" #define kSocial_QQ_Secret @"" #define kSocial_EN_Key @"" #define kSocial_EN_Secret @"" #define kSocial_Sina_RedirectURL @"" #define kSocial_Sina_OfficailAccount @"" #define kSocial_Sina_ID @"" #define kSocial_Sina_Secret @"" //信鸽推送 #define kXGPush_Id 123456 #define kXGPush_Key @"" //百度定位 #define kBaiduGeotableId @"" #define kBaiduAK @"" #define kBaiduSK @"" //测试地址 #define kBaseUrlStr_Test @"https://coding.net/" //手机版地址 #define kBaseUrlStr_Phone @"https://m.coding.net/" //Coding App 的专属链接 #define kCodingAppScheme @"coding-net:" //appStore地址 #define kAppUrl @"http://itunes.apple.com/app/id923676989" #define kAppReviewURL @"itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=923676989" //版本号 #define kVersion_Coding [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"] #define kVersionBuild_Coding [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"] //常用变量 #define DebugLog(s, ...) NSLog(@"%s(%d): %@", __FUNCTION__, __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__]) #define kTipAlert(_S_, ...) [[[UIAlertView alloc] initWithTitle:@"提示" message:[NSString stringWithFormat:(_S_), ##__VA_ARGS__] delegate:nil cancelButtonTitle:@"知道了" otherButtonTitles:nil] show] #define kKeyWindow [UIApplication sharedApplication].keyWindow #define kHigher_iOS_6_1 (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) #define kHigher_iOS_6_1_DIS(_X_) ([[NSNumber numberWithBool:kHigher_iOS_6_1] intValue] * _X_) #define kNotHigher_iOS_6_1_DIS(_X_) (-([[NSNumber numberWithBool:kHigher_iOS_6_1] intValue]-1) * _X_) #define kDevice_Is_iPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO) #define kDevice_Is_iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO) #define kDevice_Is_iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO) #define kDevice_Is_iPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO) #define kDevice_Is_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO) #define kDevice_Is_iPhoneXR ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) : NO) #define kDevice_Is_iPhoneXMax ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) : NO) #define kDevice_Is_FullScreen (kDevice_Is_iPhoneX || kDevice_Is_iPhoneXR || kDevice_Is_iPhoneXMax) #define kDevice_Is_iPad [[UIDevice currentDevice].model isEqualToString:@"iPad"] #define kDevice_Use_iPhone4_Layout (kDevice_Is_iPhone4 || kDevice_Is_iPad) #define kSafeArea_Top (kDevice_Is_FullScreen? 44: 20) #define kSafeArea_Bottom (kDevice_Is_FullScreen? 34: 0) #define kLine_MinHeight (1.0/ [UIScreen mainScreen].scale) #define kScreen_Bounds [UIScreen mainScreen].bounds #define kScreen_Height [UIScreen mainScreen].bounds.size.height #define kScreen_Width [UIScreen mainScreen].bounds.size.width #define kPaddingLeftWidth 15.0 #define kLoginPaddingLeftWidth 18.0 #define kMySegmentControl_Height 44.0 #define kMySegmentControlIcon_Height 70.0 #define kBackButtonFontSize 16 #define kNavTitleFontSize 18 #define kBadgeTipStr @"badgeTip" #define kDefaultLastId [NSNumber numberWithInteger:99999999] //#define kColorNavBG [UIColor colorWithHexString:@"0xF8F8F8"] #define kColorNavBG [UIColor colorWithHexString:@"0xFFFFFF" andAlpha:1.0] #define kColorNavTitle [UIColor colorWithHexString:@"0x323A45"] #define kColorTableBG [UIColor colorWithHexString:@"0xFFFFFF"] #define kColorTableSectionBg [UIColor colorWithHexString:@"0xF2F4F6"] #define kColor222 [UIColor colorWithHexString:@"0x222222"] #define kColor666 [UIColor colorWithHexString:@"0x666666"] #define kColor999 [UIColor colorWithHexString:@"0x999999"] //#define kColorDDD [UIColor colorWithHexString:@"0xDDDDDD"] //#define kColorCCC [UIColor colorWithHexString:@"0xCCCCCC"] #define kColorDDD kColorD8DDE4 #define kColorCCC kColorD8DDE4 #define kColorD8DDE4 [UIColor colorWithHexString:@"0xD8DDE4"] #define kColorBrandGreen [UIColor colorWithHexString:@"0x2EBE76"] #define kColorBrandBlue [UIColor colorWithHexString:@"0x0060FF"] #define kColorBrandRed [UIColor colorWithHexString:@"0xF56061"] #define kColorBrandOrange [UIColor colorWithHexString:@"0xF68435"] #define kColorLightBlue [UIColor colorWithHexString:@"0x136BFB"] #define kColorLinkBlue [UIColor colorWithHexString:@"0x2D59A2"] #pragma mark New Color #define kColorDark2 [UIColor colorWithHexString:@"0x272C33"] #define kColorDark3 [UIColor colorWithHexString:@"0x323A45"] #define kColorDark4 [UIColor colorWithHexString:@"0x425063"] #define kColorDark7 [UIColor colorWithHexString:@"0x76808E"] #define kColorDarkA [UIColor colorWithHexString:@"0xA9B3BE"] #define kColorDarkD [UIColor colorWithHexString:@"0xD8DDE4"] #define kColorDarkF [UIColor colorWithHexString:@"0xF2F4F6"] #define kColorWhite [UIColor colorWithHexString:@"0xFFFFFF"] #define kColorActionGreen [UIColor colorWithHexString:@"0x2EBE76"] #define kColorActionBlue [UIColor colorWithHexString:@"0x0060FF"] #define kColorActionRed [UIColor colorWithHexString:@"0xF56061"] #define kColorActionYellow [UIColor colorWithHexString:@"0xF3C033"] #define kPlaceholderMonkeyRoundWidth(_width_) [UIImage imageNamed:[NSString stringWithFormat:@"placeholder_monkey_round_%.0f", _width_]] #define kPlaceholderMonkeyRoundView(_view_) [UIImage imageNamed:[NSString stringWithFormat:@"placeholder_monkey_round_%.0f", CGRectGetWidth(_view_.frame)]] #define kPlaceholderCodingSquareWidth(_width_) [UIImage imageNamed:[NSString stringWithFormat:@"placeholder_coding_square_%.0f", _width_]] #define kPlaceholderCodingSquareView(_view_) [UIImage imageNamed:[NSString stringWithFormat:@"placeholder_coding_square_%.0f", CGRectGetWidth(_view_.frame)]] #define kScaleFrom_iPhone5_Desgin(_X_) (_X_ * (kScreen_Width/320)) #define kUnReadKey_messages @"messages" #define kUnReadKey_notifications @"notifications" #define kUnReadKey_project_update_count @"project_update_count" #define kUnReadKey_notification_AT @"notification_at" #define kUnReadKey_notification_Comment @"notification_comment" #define kUnReadKey_notification_System @"notification_system" //链接颜色 #define kLinkAttributes @{(__bridge NSString *)kCTUnderlineStyleAttributeName : [NSNumber numberWithBool:NO],(NSString *)kCTForegroundColorAttributeName : (__bridge id)kColorBrandGreen.CGColor} #define kLinkAttributesActive @{(NSString *)kCTUnderlineStyleAttributeName : [NSNumber numberWithBool:NO],(NSString *)kCTForegroundColorAttributeName : (__bridge id)[[UIColor colorWithHexString:@"0x1b9d59"] CGColor]} #define kTaskPrioritiesDisplay @[@"有空再看", @"正常处理", @"优先处理", @"十万火急"] ///============================================= /// @name Weak Object ///============================================= #pragma mark - Weak Object /** * @code * ESWeak(imageView, weakImageView); * [self testBlock:^(UIImage *image) { * ESStrong(weakImageView, strongImageView); * strongImageView.image = image; * }]; * * // `ESWeak_(imageView)` will create a var named `weak_imageView` * ESWeak_(imageView); * [self testBlock:^(UIImage *image) { * ESStrong_(imageView); * _imageView.image = image; * }]; * * // weak `self` and strong `self` * ESWeakSelf; * [self testBlock:^(UIImage *image) { * ESStrongSelf; * _self.image = image; * }]; * @endcode */ #define ESWeak(var, weakVar) __weak __typeof(&*var) weakVar = var #define ESStrong_DoNotCheckNil(weakVar, _var) __typeof(&*weakVar) _var = weakVar #define ESStrong(weakVar, _var) ESStrong_DoNotCheckNil(weakVar, _var); if (!_var) return; #define ESWeak_(var) ESWeak(var, weak_##var); #define ESStrong_(var) ESStrong(weak_##var, _##var); /** defines a weak `self` named `__weakSelf` */ #define ESWeakSelf ESWeak(self, __weakSelf); /** defines a strong `self` named `_self` from `__weakSelf` */ #define ESStrongSelf ESStrong(__weakSelf, _self);