1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
// // UConstants.h // Medical_Wisdom // // Created by *** on 14-3-28. // Copyright (c) 2014年 ***. All rights reserved. // #ifndef Medical_Wisdom_UConstants_h #define Medical_Wisdom_UConstants_h /******************************************************/ /**** debug log **/
//NSLog输出信息
#ifdef DEBUG #define DLog( s, ... ) NSLog( @"< %@:(%d) > %@", [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] ) #else #define DLog( s, ... ) #endif /*** DEBUG RELEASE */ #if DEBUG #define MCRelease(x) #else #define MCRelease(x) #endif /***** release *****/ #define NILRelease [x release], x = nil #pragma mark - Frame(宏 x,y,width,height) #define MainScreenScale [[UIScreen mainScreen]scale] //屏幕的分辨率 当结果为1时,显示的是普通屏幕,结果为2时,显示的是Retian屏幕 // App Frame Height&Width #define Application_Frame [[UIScreen mainScreen] applicationFrame] //除去信号区的屏幕的frame #define APP_Frame_Height [[UIScreen mainScreen] applicationFrame].size.height //应用程序的屏幕高度 #define App_Frame_Width [[UIScreen mainScreen] applicationFrame].size.width //应用程序的屏幕宽度 /*** MainScreen Height Width */ #define Main_Screen_Height [[UIScreen mainScreen] bounds].size.height //主屏幕的高度 #define Main_Screen_Width [[UIScreen mainScreen] bounds].size.width //主屏幕的宽度 // View 坐标(x,y)和宽高(width,height) #define X(v) (v).frame.origin.x #define Y(v) (v).frame.origin.y #define WIDTH(v) (v).frame.size.width #define HEIGHT(v) (v).frame.size.height #define MinX(v) CGRectGetMinX((v).frame) // 获得控件屏幕的x坐标 #define MinY(v) CGRectGetMinY((v).frame) // 获得控件屏幕的Y坐标 #define MidX(v) CGRectGetMidX((v).frame) //横坐标加上到控件中点坐标 #define MidY(v) CGRectGetMidY((v).frame) //纵坐标加上到控件中点坐标 #define MaxX(v) CGRectGetMaxX((v).frame) //横坐标加上控件的宽度 #define MaxY(v) CGRectGetMaxY((v).frame) //纵坐标加上控件的高度 #define CONTRLOS_FRAME(x,y,width,height) CGRectMake(x,y,width,height) // 系统控件的默认高度 #define kStatusBarHeight (20.f) #define kTopBarHeight (44.f) #define kBottomBarHeight (49.f) #define kCellDefaultHeight (44.f) // 当控件为全屏时的横纵左边 #define kFrameX (0.0) #define kFrameY (0.0) #define kPhoneFrameWidth (320.0) #define kPhoneWithStatusNoPhone5Height (480.0) #define kPhoneNoWithStatusNoPhone5Height (460.0) #define kPhoneWithStatusPhone5Height (568.0) #define kPhoneNoWithStatusPhone5Height (548.0) #define kPadFrameWidth (768.0) #define kPadWithStatusHeight (1024.0) #define kPadNoWithStatusHeight (1004.0) //中英状态下键盘的高度 #define kEnglishKeyboardHeight (216.f) #define kChineseKeyboardHeight (252.f) #pragma mark - Funtion Method (宏 方法) //PNG JPG 图片路径 #define PNGPATH(NAME) [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:NAME] ofType:@"png"] #define JPGPATH(NAME) [[NSBundle mainBundle] pathForResource:[NSString stringWithUTF8String:NAME] ofType:@"jpg"] #define PATH(NAME,EXT) [[NSBundle mainBundle] pathForResource:(NAME) ofType:(EXT)] //加载图片 #define PNGIMAGE(NAME) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(NAME) ofType:@"png"]] #define JPGIMAGE(NAME) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(NAME) ofType:@"jpg"]] #define IMAGE(NAME,EXT) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:(NAME) ofType:(EXT)]] #define IMAGENAMED(NAME) [UIImage imageNamed:NAME] //字体大小(常规/粗体) #define BOLDSYSTEMFONT(FONTSIZE) [UIFont boldSystemFontOfSize:FONTSIZE] #define SYSTEMFONT(FONTSIZE) [UIFont systemFontOfSize:FONTSIZE] #define FONT(NAME,FONTSIZE) [UIFont fontWithName:(NAME) size:(FONTSIZE)] //颜色(RGB) #define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]]; #define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:(a)] //当前版本 #define FSystenVersion ([[[UIDevice currentDevice] systemVersion] floatValue]) #define DSystenVersion ([[[UIDevice currentDevice] systemVersion] doubleValue]) #define SSystemVersion ([[UIDevice currentDevice] systemVersion]) //当前语言 #define CURRENTLANGUAGE ([[NSLocale preferredLanguages] objectAtIndex:0]) //是否Retina屏 #define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) :NO) //是否iPhone5 #define ISIPHONE [[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone #define ISIPHONE5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO) //是否是iPad #define isPad (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) // UIView - viewWithTag 通过tag值获得子视图 #define VIEWWITHTAG(_OBJECT,_TAG) [_OBJECT viewWithTag : _TAG] //应用程序的名字 #define AppDisplayName [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"] //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] //判断设备室真机还是模拟器 #if TARGET_OS_IPHONE /** iPhone Device */ #endif #if TARGET_IPHONE_SIMULATOR /** iPhone Simulator */ #endif #endif |