您好,欢迎来到二三四教育网。
搜索
您的当前位置:首页iOS 常用宏定义(持续更新)

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

来源:二三四教育网

常用宏定义

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

#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()

Copyright © 2019- how234.cn 版权所有 赣ICP备2023008801号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务