//获取屏幕 宽度、高度
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
#ifdef DEBUG
#define MTLog(...) NSLog(__VA_ARGS__)
#define MTMethod MTLog(@"%s",__func__)
#ifdef DEBUG # define DLog(format, ...) NSLog((@"[文件名:%s]" "[函数名:%s]" "[行号:%d]" format), __FILE__, __FUNCTION__, __LINE__, ##__VA_ARGS__); #else # define DLog(...); #endif
#else
#define MTLog(...)
#define MTMethod
#endif
#define App_Frame_Height [[UIScreen mainScreen] applicationFrame].size.height/获取屏幕高度 (不计算状态栏,就是app的范围)
#define App_Frame_Width [[UIScreen mainScreen] applicationFrame].size.width /获取屏幕宽度 (不计算状态栏,就是app的范围)
#ifdef DEBUG #define DNSLogPoint(p) NSLog(@"%f,%f", p.x, p.y) #define DNSLogSize(p) NSLog(@"%f,%f", p.width, p.height) #define DNSLogRect(p) NSLog(@"%f,%f,%f,%f", p.origin.x, p.origin.y, p.size.width, p.size.height) #els #define DNSLogPoint(p) #define DNSLogSize(p) #define DNSLogRect(p)
#endif
//读取本地图片
#define LOADIMAGE(file,ext) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:file ofType:ext]]
//定义UIImage对象
#define IMAGE(imageName) [UIImage imageNamed:[NSString stringWithFormat:@
"%@"
,imageName]]
// rgb颜色转换(16进制->10进制)
#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
]
// 获取RGB颜色
#define RGBA(r,g,b,a) [UIColor colorWithRed:r/
255
.0f green:g/
255
.0f blue:b/
255
.0f alpha:a]
#define RGB(r,g,b) RGBA(r,g,b,
1
.0f)
// 获取屏幕大小
#define kDeviceWidth [UIScreen mainScreen].bounds.size.width
#define KDeviceHeight [UIScreen mainScreen].bounds.size.height
#define IS_IOS7 (([[[UIDevice currentDevice] systemVersion] floatValue] >=
7.0
)? (YES):(NO))
#define IS_IOS6 (([[[UIDevice currentDevice] systemVersion] floatValue] >=
6.0
)? (YES):(NO))
#define IS_4INCH ([UIScreen instancesRespondToSelector:
@selector
(currentMode)] ? CGSizeEqualToSize(CGSizeMake(
640
,
1136
), [[UIScreen mainScreen] currentMode].size) : NO)
//释放内存
#define RELEASE_SAFE(_Pointer)
do
{[_Pointer release],_Pointer = nil;}
while
(
0
)
#endif
DimensMacros.h
//状态栏高度
#define STATUS_BAR_HEIGHT 20
//NavBar高度
#define NAVIGATION_BAR_HEIGHT 44
//状态栏 + 导航栏 高度
#define STATUS_AND_NAVIGATION_HEIGHT ((STATUS_BAR_HEIGHT) + (NAVIGATION_BAR_HEIGHT))
//屏幕 rect
#define SCREEN_RECT ([UIScreen mainScreen].bounds)
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
#define CONTENT_HEIGHT (SCREEN_HEIGHT - NAVIGATION_BAR_HEIGHT - STATUS_BAR_HEIGHT)
//屏幕分辨率
#define SCREEN_RESOLUTION (SCREEN_WIDTH * SCREEN_HEIGHT * ([UIScreen mainScreen].scale))
//广告栏高度
#define BANNER_HEIGHT 215
#define STYLEPAGE_HEIGHT 21
#define SMALLTV_HEIGHT 77
#define SMALLTV_WIDTH 110
#define FOLLOW_HEIGHT 220
#define SUBCHANNEL_HEIGHT 62
PathMacros.h
//文件目录
#define kPathTemp NSTemporaryDirectory()
#define kPathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]
#define kPathCache [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0]
#define kPathSearch [kPathDocument stringByAppendingPathComponent:@"Search.plist"]
#define kPathMagazine [kPathDocument stringByAppendingPathComponent:@"Magazine"]
#define kPathDownloadedMgzs [kPathMagazine stringByAppendingPathComponent:@"DownloadedMgz.plist"]
#define kPathDownloadURLs [kPathMagazine stringByAppendingPathComponent:@"DownloadURLs.plist"]
#define kPathOperation [kPathMagazine stringByAppendingPathComponent:@"Operation.plist"]
#define kPathSplashScreen [kPathCache stringByAppendingPathComponent:@"splashScreen"]
#endif
UtilsMacros.h
//Log utils marco
#define ALog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DLog(...)
#endif
#ifdef DEBUG
#define ULog(...)
//#define ULog(fmt, ...) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:[NSString stringWithFormat:@"%s\n [Line %d] ", __PRETTY_FUNCTION__, __LINE__] message:[NSString stringWithFormat:fmt, ##__VA_ARGS__] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil]; [alert show]; }
#else
#define ULog(...)
#endif
//System version utils
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
// 获取RGB颜色
#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
#define RGB(r,g,b) RGBA(r,g,b,1.0f)
#define IsPortrait ([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)
#define IsNilOrNull(_ref) (((_ref) == nil) || ([(_ref) isEqual:[NSNull null]]))
//角度转弧度
#define DEGREES_TO_RADIANS(d) (d * M_PI / 180)
//大于等于7.0的ios版本
#define iOS7_OR_LATER SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0")
//大于等于8.0的ios版本
#define iOS8_OR_LATER SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")
//iOS6时,导航VC中view的起始高度
#define YH_HEIGHT (iOS7_OR_LATER ? 64:0)
//获取系统时间戳
#define getCurentTime [NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970]]