iOS开发常用的宏(打印,约束等等)

释放双眼,带上耳机,听听看~!

//Masonry约束宏

/*****************添加约束宏(开始)*************************/
#ifdef __OBJC__
//define this constant if you want to use Masonry without the 'mas_' prefix
#define MAS_SHORTHAND
//define this constant if you want to enable auto-boxing for default syntax
#define MAS_SHORTHAND_GLOBALS
#import "Masonry.h"
#endif
/*******************添加约束宏(结束)***********************/

//RGBColor自定义的宏
#define RGBColor(_R_,_G_,_B_,_alpha_) [UIColor colorWithRed:_R_/255.0 green:_G_/255.0 blue:_B_/255.0 alpha:_alpha_]

//自定义颜色(十六进制)
#define RGBSixteenColor(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]

//DEBUG打印日志-路径

#ifdef DEBUG
#define DLog(format, ...) NSLog((@"[文件名:%@]" "[函数名:%s]" "[行号:%d]" format), [NSString stringWithUTF8String:__FILE__], __FUNCTION__, __LINE__, ##__VA_ARGS__);
#else
#define DLog(...);
#endif
#ifdef DEBUG
#define NSLog(FORMAT, ...) fprintf(stderr,"%sn",[[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define NSLog(...)
#endif

DLog(…)结果如下
DLog(@”%f”,self.hightForScroll);

[文件名:/Users/Lenn/Desktop/微信/微信端/首页/智慧列表/学情报告/LearningSituationReportViewController.m][函数名:-[LearningSituationReportViewController viewDidLoad]][行号:156]0.000000

//判断手机型号

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
#define IS_RETINA ([[UIScreen mainScreen] scale] >= 2.0)
#define SCREEN_WIDTH ([[UIScreen mainScreen] bounds].size.width)
#define SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define SCREEN_MAX_LENGTH (MAX(SCREEN_WIDTH, SCREEN_HEIGHT))
#define SCREEN_MIN_LENGTH (MIN(SCREEN_WIDTH, SCREEN_HEIGHT))
#define IS_IPHONE_4_OR_LESS (IS_IPHONE && SCREEN_MAX_LENGTH < 568.0)
#define IS_IPHONE_5 (IS_IPHONE && SCREEN_MAX_LENGTH == 568.0)
#define IS_IPHONE_6 (IS_IPHONE && SCREEN_MAX_LENGTH == 667.0)
#define IS_IPHONE_6P (IS_IPHONE && SCREEN_MAX_LENGTH == 736.0)

//手机尺寸

//屏幕宽和高
#define KWidth  [UIScreen mainScreen].bounds.size.width
#define KHeight  [UIScreen mainScreen].bounds.size.height
//比例
#define KPercentWitdh  [UIScreen mainScreen].bounds.size.width/375
#define KPercentHeight [UIScreen mainScreen].bounds.size.height/667

人已赞赏
iOS文章

解决 Xcode 报 library not found for -lstdc++ 问题

2020-2-5 12:56:14

iOS文章

ios隐藏某行cell

2020-2-5 14:28:19

个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索