123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- //
- // RDSConstant.h
- // singleProduct
- //
- // Created by coderYK on 2018/4/26.
- // Copyright © 2018年 coderYK. All rights reserved.
- //
- #import <Foundation/Foundation.h>
- //-------------------打印--------------------
- #ifdef DEBUG
- #define NEED_OUTPUT_LOG 1
- #else
- #define NEED_OUTPUT_LOG 0
- #endif
- #if NEED_OUTPUT_LOG
- #define DDLog(xx, ...) NSLog(@"%s(%d): " xx, __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
- #else
- #define DDLog(xx, ...) nil
- #endif
- // NSLog打印不全 加入后会导致控制台输出不显示时间 [[NSDate dateWithTimeIntervalSinceNow:0] timeIntervalSince1970]*1000
- #ifdef DEBUG
- #define NSLog(...) printf("%f %s\n",[[NSDate date] timeIntervalSince1970],[[NSString stringWithFormat:__VA_ARGS__]UTF8String]);
- #else
- #define NSLog(FORMAT, ...) nil
- #endif
- //-------------------打印--------------------
- #define kGetTimeNow [NSString stringWithFormat:@"%.0f", ([[NSDate dateWithTimeIntervalSinceNow:0] timeIntervalSince1970]*1000)]
- #define objectOrNull(obj) ((obj) ? (obj) : [NSNull null])
- #define objectOrEmptyStr(obj) ((obj) ? (obj) : @"")
- //判断字符串是否为空
- #define kNULLString(string) ((![string isKindOfClass:[NSString class]])||[string isEqualToString:@""] || (string == nil) || [string isEqualToString:@""] || [string isKindOfClass:[NSNull class]]||[[string stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] length]==0)
- #define isNull(x) (!x || [x isKindOfClass:[NSNull class]])
- #define toInt(x) (isNull(x) ? 0 : [x intValue])
- #define isEmptyString(x) (isNull(x) || [x isEqual:@""] || [x isEqual:@"(null)"])
- #define sleep(s); [NSThread sleepForTimeInterval:s];
- #define Syn(x) @synthesize x = _##x
- #define BoldSystemFont(size) [UIFont boldSystemFontOfSize:size]
- #define systemFont(size) [UIFont systemFontOfSize:size]
- #define beginAutoPool NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; {
- #define endAutoPool } [pool release];
- #define skipspace(c) while (isspace(*c)) ++c
- #define skipUntil(c,x) while (x != *c) ++c
- #define TheWindowHeight ([UIDevice isAfterOS7] ? [UIScreen mainScreen].bounds.size.height : ([UIScreen mainScreen].bounds.size.height - 20))
- #define isIOS7 [[UIDevice currentDevice].systemVersion doubleValue]>=7.0?YES:NO
- #define isIOS8 [[UIDevice currentDevice].systemVersion doubleValue]>=8.0?YES:NO
- #define isIOS9 [[UIDevice currentDevice].systemVersion doubleValue]>=9.0?YES:NO
- #define isIOS10 [[UIDevice currentDevice].systemVersion doubleValue]>=10.0?YES:NO
- #define isIOS11 [[UIDevice currentDevice].systemVersion doubleValue]>=11.0?YES:NO
- #define kSYSTEM_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
- #define kSTATUSBAR_HEIGHT [[UIApplication sharedApplication] statusBarFrame].size.height
- #define kNAVBAR_HEIGHT (44.f + ((kSYSTEM_VERSION >= 7) ? kSTATUSBAR_HEIGHT : 0))
- #define FULL_WIDTH SCREEN_WIDTH
- #define FULL_HEIGHT (SCREEN_HEIGHT - ((kSYSTEM_VERSION >= 7) ? 0 : kSTATUSBAR_HEIGHT))
- #define CONTENT_HEIGHT (FULL_HEIGHT - NAVBAR_HEIGHT)
- // 屏幕高度
- #define SCREEN_HEIGHT [[UIScreen mainScreen] bounds].size.height
- // 屏幕宽度
- #define SCREEN_WIDTH [[UIScreen mainScreen] bounds].size.width
- #define kSCALE_WIDTH_6 (SCREEN_WIDTH/375)
- #define kSCALE_HEIGHT_6 (SCREEN_HEIGHT/667)
- #define kSCALE_WIDTH_X (SCREEN_WIDTH/414)
- #define kSPACE_EDGE_RIGHT_LEFT (IPHONE4OR5 ? 10 : 20)
- #define IPAD9_7 SCREEN_WIDTH == 768
- #define IPHONE4OR5 ( [ [ UIScreen mainScreen ] bounds ].size.width == 320 )
- #define IPhoneX (SCREEN_HEIGHT == 812.0f || SCREEN_HEIGHT == 896.0f)
- #define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
- #define kStatusBarHeight (IPhoneX ? 44 : 20) // 状态栏高度
- #define AdaptTabHeight (IPhoneX ? 34 : 0) // Tab bar 圆角部分高度
- #define kNavHeight (IPhoneX ? 88 : 64) // 导航
- #define kTabbarHeight (IPhoneX ? 83 : 49) // 分栏
- #define kUserDefaults [NSUserDefaults standardUserDefaults]
- #define kNotificationCenter [NSNotificationCenter defaultCenter]
- #define kFileManager ([NSFileManager defaultManager])
- #define kAppDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate])
- //-------------- 单例-----------------
- #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__; \
- }
- //-------------- 单例-----------------
- //图片
- #define DD_MESSAGE_IMAGE_PREFIX @"&$#@~^@[{:"
- #define DD_MESSAGE_IMAGE_SUFFIX @":}]&$~@#@"
- // url phone email 正则
- #define URL_REGULA @"((?:(http|https|Http|Https|rtsp|Rtsp):\\/\\/(?:(?:[a-zA-Z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,64}(?:\\:(?:[a-zA-Z0-9\\$\\-\\_\\.\\+\\!\\*\\'\\(\\)\\,\\;\\?\\&\\=]|(?:\\%[a-fA-F0-9]{2})){1,25})?\\@)?)?((?:(?:[a-zA-Z0-9][a-zA-Z0-9\\-]{0,64}\\.)+(?:(?:aero|arpa|asia|a[cdefgilmnoqrstuwxz])|(?:biz|b[abdefghijmnorstvwyz])|(?:cat|com|coop|c[acdfghiklmnoruvxyz])|d[ejkmoz]|(?:edu|e[cegrstu])|f[ijkmor]|(?:gov|g[abdefghilmnpqrstuwy])|h[kmnrtu]|(?:info|int|i[delmnoqrst])|(?:jobs|j[emop])|k[eghimnrwyz]|l[abcikrstuvy]|(?:mil|mobi|museum|m[acdghklmnopqrstuvwxyz])|(?:name|net|n[acefgilopruz])|(?:org|om)|(?:pro|p[aefghklmnrstwy])|qa|r[eouw]|s[abcdeghijklmnortuvyz]|(?:tel|travel|t[cdfghjklmnoprtvwz])|u[agkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw]))|(?:(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9])\\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[1-9]|0)\\.(?:25[0-5]|2[0-4][0-9]|[0-1][0-9]{2}|[1-9][0-9]|[0-9])))(?:\\:\\d{1,5})?)(\\/(?:(?:[a-zA-Z0-9\\;\\/\\?\\:\\@\\&\\=\\#\\~\\-\\.\\+\\!\\*\\'\\(\\)\\,\\_])|(?:\\%[a-fA-F0-9]{2}))*)?(?:\\b|$)"
- #define PHONE_REGULA @"\\d{3}-\\d{8}|\\d{3}-\\d{7}|\\d{4}-\\d{8}|\\d{4}-\\d{7}|1+[358]+\\d{9}|\\d{8}|\\d{7}"
- #define EMAIL_REGULA @"[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}"
- #define LINK_SPLIT @"!@#$~link~#$@!"
- #define NICK_SPLIT @"!@#$~nick~#$@!"
- #define PHONE_SPLIT @"!@#$~phone~#$@!"
- #define EMAIL_SPLIT @"!@#$~email~#$@!"
- #define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
- #define RGB(r,g,b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0]
- #define RDSNavBarColor RGB(248,248,250)
- #define RDSViewBgColor RGB(248,248,250)
- #define RDSGreenColor RGB(20, 201, 201) // 绿色
- #define RDSLightGreenColor RGB(240, 245, 246) // 浅绿色
- #define RDSRedColor RGB(228,31,39) // 红色
- #define RDSThemeColor RGB(6,40,75) // 深空蓝
- #define RDSPinkColor RGB(204, 55, 241) // 粉红色
- #define RDSBlueColor RGB(47, 149, 250) // 蓝色
- #define RDSHeaderBgColor RGB(214, 214, 215)
- #define RDSGrayColor RGB(130, 148, 165) // 灰色
- #define RDSLightGrayColor RGB(239, 239, 239) // 浅灰色
- #define RDSBlackColor RGB(39, 46, 59) // 黑色
- // 字体颜色
- #define kTextColor RGB(85,85,85)
- #define kDarkTextColor RGBA(6, 40, 75, 1)
- //快速定义一个weakSelf 用于block
- #define RDS_WEAKSELF(weakSelf) __weak __typeof(&*self)weakSelf = self;
- #define BLOCK_SAFE_RUN(block, ...) block != nil ? block(__VA_ARGS__) : nil;
- #pragma mark - 全局常量参数
- #pragma mark - 通知
- extern NSString * const RDSDeviceCmdContentParserNotice;
- /// 用户信息更新通知
- extern NSString * const RDSUpdateUserInfoNotice;
|