美文网首页
iOS 常用宏定义(持续更新)

iOS 常用宏定义(持续更新)

作者: CCSHCoder | 来源:发表于2016-05-18 10:44 被阅读177次

常用宏定义

// 获取时间间隔(计算耗时)

#define TICK  CFAbsoluteTime start = CFAbsoluteTimeGetCurrent();

#define TOCK  NSLog(@"Time: %f", CFAbsoluteTimeGetCurrent() - start);

//是否为V以上系统

#define IOS(V) [[[UIDevice currentDevice] systemVersion]floatValue]>=V

//设置 view 圆角和边框

#define kSHViewBorderRadius(View, Radius, Width, Color)\
\
[View.layer setMasksToBounds:YES];\
[View.layer setBorderWidth:(Width)];\
[View.layer setCornerRadius:(Radius)];\
[View.layer setBorderColor:[Color CGColor]]

// 系统delegate

#define kSHAppDelegate (AppDelegate *)[UIApplication sharedApplication].delegate

//获取当前语言

#define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])

//三原色

#define kRGB(R,G,B) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:1.0]

// 字体颜色16进制0x

#define GmColorWith0xColor(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 APP_Height ([UIScreen mainScreen].bounds.size.height)

#define APP_Width ([UIScreen mainScreen].bounds.size.width)

// 界面宽高度

#define View_Width self.view.frame.size.width

#define View_Height self.view.frame.size.height

//Document目录

#define DocumentPatch NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES)[0]

//Caches目录

#define CachesPatch NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)[0]

//Temp目录

#define TempPatch NSTemporaryDirectory()

相关文章

网友评论

      本文标题:iOS 常用宏定义(持续更新)

      本文链接:https://www.haomeiwen.com/subject/mpcwrttx.html