| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- //
- // Common.h
- // kneet2
- //
- // Created by Created by Jason Lee on 10/1/15.
- // Copyright (c) 2015 ntels. All rights reserved.
- //
- #ifndef kneet2_Common_h
- #define kneet2_Common_h
- //iphone window
- //320 x 480 pts 320 x 568 pts 375 x 667 pts 414 x 736 pts
- //ipad
- //1024x768 1024x768
- #define STATUS_BAR_HEIGHT [UIApplication sharedApplication].statusBarFrame.size.height
- #define IPHONE_WIDTH [UIScreen mainScreen].bounds.size.width
- #define IPHONE_HEIGHT [[UIScreen mainScreen] bounds].size.height
- #define IPHONE_NAVIGATIONBAR_HEIGHT 65
- #define IPHONE_MARGIN_BOTTOM 49
- #define SEARCHBAR_HEIGHT 44
- #define PORTRAIT_KEYBOARD_HEIGHT 216
- #define LANDSCAPE_KEYBOARD_HEIGHT 162
- #define KEYBOARD_ACCESSORY_HEIGHT 44
- #define KEYBOARD_PREDICTS_HEIGHT ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.000000 ? 40 : 0)
- #define CGRectCenter(rect) CGRectMake((rect.size.width / 2.0f), (rect.size.height / 2.0f), rect.size.width, rect.size.height)
- #define CGRectCenterPos(rect) CGRectMake(rect.origin.x + (rect.size.width / 2.0f), rect.origin.y + (rect.size.height / 2.0f), rect.size.width, rect.size.height)
- //DEVICE
- #define DEVICE_MODEL [[UIDevice currentDevice] localizedModel]
- #define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
- #define kfAnimationDur [[[UIDevice currentDevice] systemVersion] floatValue] >= 5.000000 ? 0.25f : 0.3f
- //UI
- #define IS_RETINA ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] && ([UIScreen mainScreen].scale == 2.0))
- #define IS_4INCH_SCREEN CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(320, 568)) || CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(568, 320))
- #define IS_35INCH_SCREEN CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(320, 480)) || CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(480, 320))
- #define IS_IPHONE_5 CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(320, 568)) || CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(568, 320))
- #define IS_IPHONE_6 CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(375, 667.0f)) || CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(667.0f, 375))
- #define IS_IPHONE_6P CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(414, 736.0f)) || CGSizeEqualToSize([UIScreen mainScreen].bounds.size, CGSizeMake(736.0f, 414))
- #define IS_IPAD [[[UIDevice currentDevice] systemVersion] floatValue] >= 8.3 ? (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) : [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad
- #define AUTO_NIB(NIB_NAME) IS_IPAD?[NSString stringWithFormat:@"%@_iPad", NIB_NAME]:IS_4INCH_SCREEN?[NSString stringWithFormat:@"%@_4Inch", NIB_NAME]:NIB_NAME
- //Network
- #define ksHTTPRequestPOST @"POST"
- #define ksHTTPRequestGET @"GET"
- #define ksHTTPRequestDELETE @"DELETE"
- #define ksHTTPRequestPUT @"PUT"
- #define kDefaultTimeOut 30
- #define ksHTTPMultipartForm @"MULTIPART_FORM"
- #define ksCustomRadioButtonObject @"RADIO_OBJECT"
- #define ksCustomRadioButtonStatus @"RADIO_STATUS"
- #define ksCustomCheckBoxStatus @"CHECK_STATUS"
- //COLOR
- #define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1]
- #define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]
- //MATH
- #define DEGREES(radians)((radians) * 180 / M_PI)
- #define RADIANS(degree)((degree) * M_PI / 180)
- //STRING
- #define ksEmptyString @""
- //LOCALIZATION
- #define LocalizedString(String) NSLocalizedString((String), nil)
- #define RECT_X(view) view.frame.origin.x
- #define RECT_Y(view) view.frame.origin.y
- #define RECT_WIDTH(view) view.frame.size.width
- #define RECT_HEIGHT(view) view.frame.size.height
- //LOG
- // XCodeColors
- #define XCODE_COLORS_ESCAPE @"\033["
- #define XCODE_COLORS_RESET_FG XCODE_COLORS_ESCAPE @"fg;" // Clear any foreground color
- #define XCODE_COLORS_RESET_BG XCODE_COLORS_ESCAPE @"bg;" // Clear any background color
- #define XCODE_COLORS_RESET XCODE_COLORS_ESCAPE @";" // Clear any foreground or background color
- #ifdef DEBUG_MODE
- static const int ddLogLevel = DDLogLevelDebug;
- #define NSLogObj(x) DDLogDebug(@"%@", x)
- #define NSLogPoint(x) DDLogDebug(@"%s, %@", __PRETTY_FUNCTION__, NSStringFromCGPoint(x))
- #define NSLogSize(x) DDLogDebug(@"%s, %@", __PRETTY_FUNCTION__, NSStringFromCGSize(x))
- #define NSLogRect(x) DDLogDebug(@"%s, %@", __PRETTY_FUNCTION__, NSStringFromCGRect(x))
- #define NSLogFunc() DDLogDebug(@"%s", __PRETTY_FUNCTION__)
- #define NSLogFuncObj(x) DDLogDebug(@"%s, %@", __PRETTY_FUNCTION__, x)
- #define NSLog(format, ...) DDLogDebug(@"[%s(%d)] %@", __PRETTY_FUNCTION__, __LINE__, [NSString stringWithFormat:(format), ##__VA_ARGS__])
- #define SHOW_DICTIONARY_INFO(dict) {NSLog(@"***** Displaying Dictionary Information *****"); for (NSString *key in dict.allKeys) NSLog(@"[%@] : %@", key,[dict objectForKey:key]); NSLog(@"***** Finished Dictionary Information *****");}
- // #define NSLog(format, ...) DDLogDebug(format, ## __VA_ARGS__)
- // #define NSLog( s, ... ) NSLog( @"[%s(%d)] %@", __PRETTY_FUNCTION__, __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
- //NSLog( @"[%@ %s(%d)] %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __PRETTY_FUNCTION__, __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
- #define NSLogInfo(format, ...) DDLogDebug((XCODE_COLORS_ESCAPE @"fg0,0,200;" format XCODE_COLORS_RESET), ##__VA_ARGS__)
- // #define NSLog(format, ...) DDLogDebug((XCODE_COLORS_ESCAPE @"fg231,76,60;%s[Line %d] " format XCODE_COLORS_RESET), __PRETTY_FUNCTION__, __LINE__, ## __VA_ARGS__)
- // #define NSLog(format, ...) DDLogDebug((XCODE_COLORS_ESCAPE @"fg231,76,60;%s[Line %d] " fmt XCODE_COLORS_RESET),format, ## __VA_ARGS__)
- #else
- #ifdef PRODUCT_MODE //운영모드 일 경우, 로그를 출력하지 않음
- static const int ddLogLevel = DDLogLevelError;
- #define NSLogObj(x)
- #define NSLogPoint(x)
- #define NSLogSize(x)
- #define NSLogRect(x)
- #define NSLogFunc()
- #define NSLogFuncObj(x)
- #define NSLog(format, ...)
- #else
- static const int ddLogLevel = DDLogLevelDebug;
- #define NSLogObj(x) DDLogDebug(@"%@", x)
- #define NSLogPoint(x) DDLogDebug(@"%s, %@", __PRETTY_FUNCTION__, NSStringFromCGPoint(x))
- #define NSLogSize(x) DDLogDebug(@"%s, %@", __PRETTY_FUNCTION__, NSStringFromCGSize(x))
- #define NSLogRect(x) DDLogDebug(@"%s, %@", __PRETTY_FUNCTION__, NSStringFromCGRect(x))
- #define NSLogFunc() DDLogDebug(@"%s", __PRETTY_FUNCTION__)
- #define NSLogFuncObj(x) DDLogDebug(@"%s, %@", __PRETTY_FUNCTION__, x)
- #define NSLog(format, ...) DDLogDebug(format, ## __VA_ARGS__)
- #endif
- #endif
- //// DLog
- //#ifdef DEBUG
- //#define DLog(fmt, ...) CLSNSLog((@"%s[Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
- //#define DLogError(fmt, ...) CLSNSLog((XCODE_COLORS_ESCAPE @"fg231,76,60;%s[Line %d] " fmt XCODE_COLORS_RESET), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
- //#define DLogWarn(fmt, ...) CLSNSLog((XCODE_COLORS_ESCAPE @"fg241,196,15;%s[Line %d] " fmt XCODE_COLORS_RESET), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
- //#define DLogInfo(fmt, ...) CLSNSLog((XCODE_COLORS_ESCAPE @"fg26,188,156;%s[Line %d] " fmt XCODE_COLORS_RESET), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
- //#else
- //#define DLog(fmt, ...) CLSLog((@"%s[Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
- //#define DLogError(fmt, ...) CLSLog((@"%s[Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
- //#define DLogWarn(fmt, ...) CLSLog((@"%s[Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
- //#define DLogInfo(fmt, ...) CLSLog((@"%s[Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__)
- //#endif
- #endif
|