美文网首页
常用宏定义

常用宏定义

作者: UILabelkell | 来源:发表于2017-11-26 11:25 被阅读9次

//屏幕尺寸

define SCREEN_WIDTH [UIScreen mainScreen].bounds.size.width

define SCREENH_HEIGHT [UIScreen mainScreen].bounds.size.height

//颜色

define RGB(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]

define RGBA(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:(a)]

//(随机色)

define LRRandomColor [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1.0]

//常用工具类
//(弱引用/强引用)

define LRWeakSelf(type) __weak typeof(type) weak##type = type;

define LRStrongSelf(type) __strong typeof(type) strong##type = weak##type;

//设置 view 圆角和边框

define LRViewBorderRadius(View, Radius, Width, Color)\


[View.layer setCornerRadius:(Radius)];
[View.layer setMasksToBounds:YES];
[View.layer setBorderWidth:(Width)];
[View.layer setBorderColor:[Color CGColor]]

//APP版本号

define kAppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

//系统版本号

define kSystemVersion [[UIDevice currentDevice] systemVersion]

//获取当前语言

define kCurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])

//判断是否为iPhone

define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)

//判断是否为iPad

define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

//判断是否为ipod

define IS_IPOD ([[[UIDevice currentDevice] model] isEqualToString:@"iPod touch"])

相关文章

  • iOS 常用宏定义

    常用宏定义

  • iOS开发常用的宏定义

    Objective-C常用宏/*! 字体 */ /*! 颜色宏定义 */ /*! 弱引用宏 */ /*! 输出显示...

  • 常用宏定义

    // HGBMacroConfig.h #ifndef HGBMacroConfig_h #define HGBM...

  • 常用宏定义

    //屏幕尺寸 define SCREEN_WIDTH [UIScreen mainScreen].bounds...

  • 常用宏定义

    1.color #define COlOR(R,G,B,A) [UIColor colorWithRed:(R)/...

  • 常用宏定义

    1、屏幕尺寸 2、UIView相关 3、常用颜色 4、手机版本 5、沙盒

  • 常用宏定义

    未完待续 持续更新中 1. 字符串判空处理 2.获取屏幕宽高 3.Log输出样式修改 呈现效果 4.宏定义单例 5...

  • 常用宏定义

    优点 提高了程序的可读性,同时也方便进行修改,用户只需要在一处定义,多处使用,修改也只需要修改一处 提高程序的运行...

  • iOS 常用宏定义

    iOS 开发中使用一些常用宏定义可以大大提高开发效率,提高代码的重用性.以下是一些常用的宏定义: 像这些宏定义,在...

  • 宏定义指令

    常用的宏定义指令 详细应用

网友评论

      本文标题:常用宏定义

      本文链接:https://www.haomeiwen.com/subject/lcdkbxtx.html