iOS 项目中经常会用到的宏定义

    说下项目中,经常会遇到的宏定义。废话不多说,直接上代码。

    

#define ISIPHONE5 ((double)[[UIScreen mainScreen] bounds].size.height>=568 ? 1 : 0)
#define ISIOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7 ? 1 : 0)
#define RGBCOLOR(r,g,b) [UIColor colorWithRed:(r)/255.0f green:(g)/255.0f blue:(b)/255.0f alpha:1]


#define VERSION [[UIDevice currentDevice].systemVersion doubleValue]
#define NAVIGATION_HEIGHT ((VERSION<7.0f)?44:64)
#define WIN_SIZE [[UIScreen mainScreen] bounds].size
#define WIN_WIDTH WIN_SIZE.width
#define WIN_HEIGHT ((VERSION<7.0f)?(WIN_SIZE.height-20):(WIN_SIZE.height))
#define ISNETWORK [[GBObject sharedInstance]isReachable]


#define X(v)                    (v).frame.origin.x
#define Y(v)                    (v).frame.origin.y
#define WIDTH(v)                (v).frame.size.width
#define HEIGHT(v)               (v).frame.size.height
#define CHILD_X   ((VERSION<7.0f)?15:0)

#define SELF_HEIGHT             self.view.frame.size.height
#define USER_DEFAULT [NSUserDefaults standardUserDefaults]

#define DATA_ENV [DataEnvironment sharedDataEnvironment]

#define ImageNamed(_pointer) [UIImage imageNamed:[UIUtil imageName:_pointer]]


#pragma mark - common functions 

#define RELEASE_SAFELY(__POINTER) { [__POINTER release]; __POINTER = nil; }


#pragma mark - degrees/radian functions 

#define degreesToRadian(x) (M_PI * (x) / 180.0)

#define radianToDegrees(radian) (radian*180.0)/(M_PI)


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值