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)
#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)
相关文章推荐
- iOS拨打电话功能的实现
- 16进制色值
- 调用iOS系统拨打手机号码的三种方式
- ios学习笔记之-点击一个按钮弹出拨打电话提示框
- 关于iOS TableView旋转后头部空白的问题
- 创建对象使用 new 和 alloc init的区别
- iOS实现简单图文混排效果
- JSPatch-iOS热补丁方式快速修复bug
- iOS自定义tabbar(没有tabbar上的黑线)
- iOS开发之pickerView 制作省份选择器
- iOS PushMeBaby日志提示SSLwrite():-36 94
- iOS 第三方框架-MBProgressHUD mark下
- iOS定时器
- iOS - 类簇
- iOS开发者账户添加测试手机UDID方法
- iOS的逆向传值有很多种方法,下面来总结几种常用的传值方式(只贴相关代码):
- ios 通过代码调节屏幕亮度
- iOS runtime实战应用:成员变量和属性
- iOS核心动画高级技巧(1)
- iOS开发--3D Touch的基本使用