123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- #ifndef UtilsMacro_h
- #define UtilsMacro_h
- #import "UIColor+MT.h"
- #import "AppDelegate.h"
- #import "MTDevicesTool.h"
- #define KWINDOW [UIApplication sharedApplication].keyWindow
- #define ROOTVC KWINDOW.rootViewController
- #define CURRENT_NAV \
- ({ \
- RDVTabBarController *rootVc = (RDVTabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController
- CustomNavigationController *currentNav = (CustomNavigationController*)rootVc
- (currentNav)
- })
- #define APPDELEGATE (AppDelegate *)[UIApplication sharedApplication].delegate
- #define iphoneX [MTDevicesTool isIphoneX]
- #define iphoneXSM [MTDevicesTool isIphoneXSM]
- #define iPhone_model [MTDevicesTool iphoneModel]
- #define iPhone_verson [[UIDevice currentDevice] systemVersion]
- #define APP_NAME [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDisplayName"]
- #define APP_BUILDVERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"];
- #define APP APP_RELEASEVERSION [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
- #define rgb(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
- #define UIColorFromRGBString(rgbValue,a) [UIColor colorWithRed:((float)(((rgbValue) & 0xFF0000) >> 16))/255.0 green:((float)(((rgbValue) & 0xFF00)>>8))/255.0 blue: ((float)((rgbValue) & 0xFF))/255.0 alpha:(a)]
- #define UIColorFromRGB(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 HColor(hString) [UIColor mt_colorWithHexString:hString]
- #define MainColor HColor(@"45E6B0")
- #define MainBgColor HColor(@"FAFBFD")
- #define ImageFile(A) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:A ofType:nil]]
- #define ImageNamed(name) [UIImage imageNamed:name]
- #define ScreenWidth ([[UIScreen mainScreen]bounds].size.width)
- #define ScreenHeight ([[UIScreen mainScreen]bounds].size.height)
- #define ViewWidth(v) v.frame.size.width
- #define ViewHeight(v) v.frame.size.height
- #define ViewX(v) v.frame.origin.x
- #define ViewY(v) v.frame.origin.y
- #define SelfViewHeight self.view.bounds.size.height
- #define kNumFrom375(a) (ScreenWidth/375 * a)
- #define kNumFrom667(a) (ScreenHeight/667 * a)
- #define tabBarHeight [MTDevicesTool tabBaritemHeight]
- #define toolBarHeight [MTDevicesTool toolBarHeightMethod]
- #define navHeight [MTDevicesTool navBarHeight]
- #define statusHeight [MTDevicesTool statusBarHeight]
- #define bold(S) [UIFont boldSystemFontOfSize:kNumFrom375(S)]
- #define font(S) [UIFont systemFontOfSize:kNumFrom375(S)]
- #define IF_NULL_TO_STRING(x) ([(x) isEqual:[NSNull null]]||(x)==nil)? @"":TEXT_STRING(x)
- #define TEXT_STRING(x) [NSString stringWithFormat:@"%@",x]
- #define ResignAllResponder [[UIApplication sharedApplication].keyWindow endEditing:YES];
- #define USERDEFAULTS [NSUserDefaults standardUserDefaults]
- #define NSUserDefaultRemove(KEY) [[NSUserDefaults standardUserDefaults] removeObjectForKey:KEY];
- #define NSUserDefaultObjectForKey(KEY) [[NSUserDefaults standardUserDefaults]objectForKey:KEY]
- #define NSUserDefaultSetObject(VALUE,KEY) \
- [[NSUserDefaults standardUserDefaults] setObject:VALUE forKey:KEY]
- [[NSUserDefaults standardUserDefaults] synchronize]
- #define HTMLString(HTML) \
- ({ \
- NSString *head=@"<head> <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, user-scalable=no\"><style> img{max-width: 100%; height:auto !important;} body{ background-color: #ffffff;font-size:large;padding: 0 10px;}</style></head>"
- NSString *resultStr
- resultStr = [NSString stringWithFormat:@"<!DOCTYPE html> %@ <body> %@ </body> </html>",head,HTML]
- (resultStr)
- })
- #define ParaOfIOS_URL(URL) \
- ({ \
- NSRange range = [URL rangeOfString:@"?"]
- NSString *propertys = [URL substringFromIndex:(int)(range.location+1)]
- NSArray *subArray = [propertys componentsSeparatedByString:@"&"]
- NSMutableDictionary *tempDic = [NSMutableDictionary dictionaryWithCapacity:4]
- for (int j = 0
- NSArray *dicArray = [subArray[j] componentsSeparatedByString:@"="]
- [tempDic setObject:dicArray[1] forKey:dicArray[0]]
- }\
- (tempDic)
- })
- #define GetClassName(URL) \
- ({\
- NSRange range = [URL rangeOfString:@"?"]
- NSString *className = [URL substringToIndex:(int)(range.location)]
- (className)
- })
- #endif
|