#define

作者: 弗利撒 | 来源:发表于2017-11-24 09:05 被阅读0次

不应当急于求成,应当去熟悉自己的研究对象,锲而不舍,时间会成全一切。凡事开始最难,然而更难的是何以善终。——莎士比亚


今天分享一些开发时常用的“#define”(说实话 我一直在用这个,就是不知道叫什么,😓)

//RGB颜色

#define Color(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]

//带有透明度的RGB颜色

#define ColorAlpha(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)]

/** 随机颜色 */

#define randomColor Color(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))

宽度 和高度

#define Screen_Width [UIScreen mainScreen].bounds.size.width

#define Screen_Height [UIScreen mainScreen].bounds.size.height 

弱引用

#define WS(b_self) __weak __typeof(&*self)b_self = self

/** 时间戳 */

#define TIME [DES3Util getCurrentDateString]

/** 通知中心 */

#define GJYNotification [NSNotificationCenter defaultCenter]

/** 系统版本号 */

#define IOSSystemVersion [[UIDevice currentDevice].systemVersion floatValue]

这些是我常用的,不常用的,大家都能找到。👇是SD计算缓存大小和清除缓存

//计算检查缓存大小

float tmpSize = [[SDImageCache sharedImageCache]checkTmpSize];

NSLog(@"%f",tmpSize);

self.clearCacheName = tmpSize >= 1 ? [NSString stringWithFormat:@"%.1fM",tmpSize] : [NSString stringWithFormat:@"%.1fK",tmpSize * 1024];

//清除缓存

- (void)clearTmpPics{

[[SDImageCache sharedImageCache] clearDisk];

[[SDImageCache sharedImageCache] clearMemory];//可有可无

}

文笔不好,见谅!

有不对的地方欢迎来指导!

相关文章

网友评论

      本文标题:#define

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