IOS开发常用宏定义

//
//  GlobalDefine.h
//  TestVC
//
//  Created by apple on 15/5/12.
//  Copyright (c) 2015年 wenkai. All rights reserved.
//

#ifndef TestVC_GlobalDefine_h
#define TestVC_GlobalDefine_h

//获取屏幕 宽度、高度
#define SCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
#define SCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)

//UIImage的创建 此加载方式会加载到缓存中  占用内存
#define PNG(imageName) [UIImage imageNamed:[NSString stringWithFormat:@"%@.png",imageName]]
#define JPG(imageName) [UIImage imageNamed:[NSString stringWithFormat:@"%@.jpg",imageName]]
//UIImage的创建 此加载方式会加载到缓存中  不占用内存
#define PNG_N(imageName) [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@.png",imageName]]
#define JPG_N(imageName) [[UIImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@.jpg",imageName]]

//格式化字符串
#define STR_FORMAT(format ,str) [NSString stringWithFormat:format ,str]

//自定义打印信息打印出行号
#ifndef __OPTIMIZE__
#define NSLog(...) NSLog(__VA_ARGS__)
#define DLog(...) NSLog(@"%d行:%@", __LINE__, [NSString stringWithFormat:__VA_ARGS__])
#else
#define NSLog(...) {}
#define DLog(...) {}
#endif

//自定义颜色
#define RGB(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1.0f]
#define RGBA(r,g,b,a) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:a]
//清除背景色
#define CLEARCOLOR [UIColor clearColor]

//获取系统版本
#define IOS_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
#define CurrentSystemVersion [[UIDevice currentDevice] systemVersion]

//G-C-D
#define BACK(block) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), block)
#define MAIN(block) dispatch_async(dispatch_get_main_queue(),block)

//NSUserDefaults 实例化
#define USER_DEFAULT [NSUserDefaults standardUserDefaults]

//由角度获取弧度 有弧度获取角度
#define degreesToRadian(x) (M_PI * (x) / 180.0)
#define radianToDegrees(radian) (radian*180.0)/(M_PI)

#endif

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值