您的位置:首页 > 移动开发 > IOS开发

iOS 常用的宏定义

2016-03-24 13:04 495 查看
#define APP_WINDOW [[[UIApplication sharedApplication] delegate] window]

#define SHOW_ALERT(msg) UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示"message:msg
delegate:nil cancelButtonTitle:@"确定"otherButtonTitles:nil,
nil];\

[alert show];

//宏定义偏好设置
#define USER_D [NSUserDefaults standardUserDefaults]

//宏定义字体
#define COMMON_FONT [UIFont fontWithName:@"MicrosoftYaHei"size:15]

//拨打电话
#define PHONE(number) UIWebView * callWebview = [[UIWebView alloc] init];\

[callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",number]]]];\

[self.view addSubview:callWebview];

//通知中心
#define NOTI_CENTENT [NSNotificationCenter defaultCenter]

#define ScreenSize           [[UIScreen mainScreen] bounds].size

//屏幕的宽iPhone iPad通用
#define ScreenWidth (([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)
? [[UIScreen mainScreen] bounds].size.width : [[UIScreen mainScreen] bounds].size.height)
//屏幕的高iPhone iPad通用
#define ScreenHeight (([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown)
? [[UIScreen mainScreen] bounds].size.height : [[UIScreen mainScreen] bounds].size.width)

//Document下文件的路径,可直接NSDictionary
*dictionary=[[NSDictionary alloc]initWithContentsOfFile:PlistFilePathName];
#define PlistFilePathName [(NSString *)( (NSArray *)NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES )[0])
stringByAppendingPathComponent:@"currentuserinfo.plist"]

/**十进制颜色色值转系统颜色
*/
#define RGBACOLOR(r,g,b,a) [UIColor colorWithRed:(r)/255.0fgreen:(g)/255.0fblue:(b)/255.0falpha:(a)]

/**十六进制颜色转系统颜色
*/
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue &0xFF0000)
>>16))/255.0green:((float)((rgbValue
&0xFF00) >>8))/255.0blue:((float)(rgbValue
&0xFF))/255.0alpha:1.0]

/** iOS系统版本*/

#define SYSTEM_VERSION() [[UIDevice currentDevice].systemVersion floatValue]

#define ios9x [[[UIDevice currentDevice] systemVersion] floatValue] >=9.0f

/**iOS手机型号*/
#define iphone4x_3_5 ([UIScreen mainScreen].bounds.size.height==480.0f)

#define iphone5x_4_0 ([UIScreen mainScreen].bounds.size.height==568.0f)

#define iphone6_4_7 ([UIScreen mainScreen].bounds.size.height==667.0f)

#define iphone6Plus_5_5 ([UIScreen mainScreen].bounds.size.height==736.0f)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息