美文网首页
常用宏定义

常用宏定义

作者: 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"])

    相关文章

      网友评论

          本文标题:常用宏定义

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