iOS开发中一些常用的宏

都是挺常见的宏的应用,就不再一一注释了,权当做自己的一个笔记好了。

#define APP  [UIApplication sharedApplication]
#define APP_KEYWINDOW [UIApplication sharedApplication].keyWindow

#define HOME [TabBarControllerConfig Instance]

#define DeviceBounds [UIScreen mainScreen].bounds
#define DeviceBounds_WIDTH [UIScreen mainScreen].bounds.size.width
#define DeviceBounds_HEIGHT [UIScreen mainScreen].bounds.size.height

#define SCREEN_W DeviceBounds_WIDTH
#define SCREEN_H DeviceBounds_HEIGHT

#define IOS_35_SCREEN       [[UIScreen mainScreen] bounds].size.height <= 480.0//320*480
#define IOS_4_SCREEN       [[UIScreen mainScreen] bounds].size.height > 480.0 && [[UIScreen mainScreen] bounds].size.height < 600.0//320*568
#define IOS_47_SCREEN       [[UIScreen mainScreen] bounds].size.height > 600.0 && [[UIScreen mainScreen] bounds].size.height < 700.0//375*667
#define IOS_55_SCREEN       [[UIScreen mainScreen] bounds].size.height > 700.0//414*736

#define DEVICE_PHONE        ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
#define DEVICE_PAD          (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)


#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]
#define UIColorFromRGBWithAlpha(rgbValue,alphaValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:alphaValue]
#endif


#define LS(str)  NSLocalizedString(str, nil)

#define SUBFIX(str)  ([NSString stringWithFormat:@"%@%@",[self class],str])
#define StrFromInt(int)   ([NSString stringWithFormat:@"%d",int])
#define StrFromLong(long)   ([NSString stringWithFormat:@"%ld",long])
#define StrFromLonglong(longlong)   ([NSString stringWithFormat:@"%lld",longlong])
#define StrFromFloat(float)   ([NSString stringWithFormat:@"%f",float])


#ifdef DEBUG
#define NSLog(...) NSLog(__VA_ARGS__)
#define DLog(fmt,...) NSLog((@"%@ [line %u]: " fmt), NSStringFromClass(self.class), __LINE__, ##__VA_ARGS__)
#else
#define NSLog(...)
#define DLog(...)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值