iOS 常用宏
来源:互联网 发布:编程入门教学视频 编辑:程序博客网 时间:2024/06/07 06:51
// --------------屏幕宽高--------------------
#define ScreenWidth ([UIScreen mainScreen].bounds.size.width)
#define Screenheight ([UIScreen mainScreen].bounds.size.height)
//----------------------图片类---------------------------
//读取本地图片
#define LOADIMAGE(file,ext) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle]pathForResource:file ofType:ext]]
//定义UIImage对象
#define IMAGE(A) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:A ofType:nil]]
//----------------------颜色类---------------------------
// aqua 浅蓝
#define qianLanColor [UIColor colorWithRed:0.000 green:0.502 blue:1.000 alpha:1.000]
// sky 天蓝
#define tianLanColor [UIColor colorWithRed:0.400 green:0.800 blue:1.000 alpha:1.000]
// 浅红
#define qianHongColor [UIColor colorWithRed:1.000 green:0.400 blue:0.400 alpha:1.000]
// 蓝紫色
#define lanZiColor [UIColor colorWithRed:0.400 green:0.400 blue:1.000 alpha:1.000]
#define hui1Color [UIColor colorWithWhite:0.902 alpha:1.000]// 1灰
#define hui2Color [UIColor colorWithWhite:0.800 alpha:1.000]// 2灰
#define hui3Color [UIColor colorWithWhite:0.702 alpha:1.000]// 3灰
#define hui4Color [UIColor colorWithWhite:0.600 alpha:1.000]// 4灰
#define hui5Color [UIColor colorWithWhite:0.502 alpha:1.000]// 5灰
#define hui6Color [UIColor colorWithWhite:0.498 alpha:1.000]// 6灰
#define hui7Color [UIColor colorWithWhite:0.400 alpha:1.000]// 7灰
#define hui8Color [UIColor colorWithWhite:0.298 alpha:1.000]// 8灰
#define hui9Color [UIColor colorWithWhite:0.200 alpha:1.000]// 9灰
#define hui10Color [UIColor colorWithWhite:0.098 alpha:1.000]// 10灰
// rgb颜色转换(16进制->10进制)
#define UIColorFromRGB(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]
//带有RGBA的颜色设置
#define COLOR(R, G, B, A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]
// 获取RGB颜色
#define RGBA(r,g,b,a) [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:a]
#define RGB(r,g,b) RGBA(r,g,b,1.0f)
// 随机色
#define WZYRandomColor [UIColor colorWithRed:arc4random_uniform(256) /255.0 green:arc4random_uniform(256) /255.0 blue:arc4random_uniform(256) /255.0 alpha:1]
//随机色透明度
#define WZYRandomColorWithAlpha(a) [UIColor colorWithRed:arc4random_uniform(256) /255.0 green:arc4random_uniform(256) /255.0 blue:arc4random_uniform(256) /255.0 alpha:(a)]
//清除背景色
#define CLEARCOLOR [UIColor clearColor]
//获取系统版本
#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
#define CurrentSystemVersion [[UIDevice currentDevice] systemVersion]
//获取当前语言
#define CurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
//单例化一个类
#define SYNTHESIZE_SINGLETON_FOR_CLASS(classname) \
\
static classname *shared##classname = nil; \
\
+ (classname *)shared##classname \
{ \
@synchronized(self) \
{ \
if (shared##classname == nil) \
{ \
shared##classname = [[self alloc] init]; \
} \
} \
\
return shared##classname; \
} \
\
+ (id)allocWithZone:(NSZone *)zone \
{ \
@synchronized(self) \
{ \
if (shared##classname == nil) \
{ \
shared##classname = [super allocWithZone:zone]; \
return shared##classname; \
} \
} \
\
return nil; \
} \
\
- (id)copyWithZone:(NSZone *)zone \
{ \
return self; \
}
- iOS开发常用宏
- iOS 常用的宏
- ios 常用宏
- IOS 常用宏定义
- iOS开发常用宏
- iOS常用的宏
- iOS常用宏定义
- iOS 常用宏定义
- ios常用宏定义
- IOS 常用宏定义
- iOS 常用宏
- IOS常用宏定义
- IOS之常用宏
- IOS 常用宏定义
- IOS常用宏定义
- ios常用宏定义
- IOS常用宏定义
- iOS常用宏定义
- 邮件正则表达式
- OPC 统一架构的优势
- shimmer让你的view闪烁起来
- 安卓自定义theme以及attrs,styles资源文件详解(一)
- Bind event to element using pure Javascript
- iOS 常用宏
- 外观模式
- 关于xtk.js的使用(医疗影像处理插件)
- 【设计模式】单例模式
- android 版本更新
- linux平台下防火墙iptables原理
- 下载Apache
- 牛刀与小试-dubbo+spring-boot
- 未来值得关注的十大 APP、Web 界面设计趋势