zoukankan      html  css  js  c++  java
  • ios-常用宏

    #ifndef PrefixHeader_pch
    #define PrefixHeader_pch
    
    //共同方法
    #import "Common.h"
    
    #ifdef DEBUG
    #define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
    #else
    #define DLog(...)
    #endif
    
    
    //弱引用/强引用
    #define LRWeakSelf(type)  __weak typeof(type) weak##type = type;
    #define LRStrongSelf(type)  __strong typeof(type) type = weak##type;
    
    
    #define SCREEN_WIDTH   [UIScreen mainScreen].bounds.size.width
    #define SCREENH_HEIGHT [UIScreen mainScreen].bounds.size.height
    
    
    //字典非空判断
    #define MySetValue(dict, value) ((!dict[value] || [dict[value] isKindOfClass:[NSNull class]])?@"":dict[value])
    
    
    
    //获取通知
    #define LRNotificationCenter [NSNotificationCenter defaultCenter]
    //随机颜色
    #define LRRandomColor [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1.0]
    
    //RGB
    #define LRRGBColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
    #define LRRGBAColor(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(r)/255.0 blue:(r)/255.0 alpha:a]
    // clear背景颜色
    #define LRClearColor [UIColor clearColor]
    
    
    #ifdef DEBUG
    #define LRLog(...) NSLog(@"%s 第%d行 
     %@
    
    ",__func__,__LINE__,[NSString stringWithFormat:__VA_ARGS__])
    #else
    #define LRLog(...)
    #endif
    
    
    //空间 圆角、边宽、颜色
    #define LRViewBorderRadius(View, Radius, Width, Color)
    
    [View.layer setCornerRadius:(Radius)];
    [View.layer setMasksToBounds:YES];
    [View.layer setBorderWidth:(Width)];
    [View.layer setBorderColor:[Color CGColor]]
    
    
    //判断是否为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"])
    // 判断是否为 iPhone 5SE
    #define iPhone5SE [[UIScreen mainScreen] bounds].size.width == 320.0f && [[UIScreen mainScreen] bounds].size.height == 568.0f
    // 判断是否为iPhone 6/6s
    #define iPhone6_6s [[UIScreen mainScreen] bounds].size.width == 375.0f && [[UIScreen mainScreen] bounds].size.height == 667.0f
    // 判断是否为iPhone 6Plus/6sPlus
    #define iPhone6Plus_6sPlus [[UIScreen mainScreen] bounds].size.width == 414.0f && [[UIScreen mainScreen] bounds].size.height == 736.0f
    //获取系统版本
    #define IOS_SYSTEM_VERSION [[[UIDevice currentDevice] systemVersion] floatValue]
    //判断 iOS 8 或更高的系统版本
    #define IOS_VERSION_8_OR_LATER (([[[UIDevice currentDevice] systemVersion] floatValue]
    
    //获取temp
    #define kPathTemp NSTemporaryDirectory()
    //获取沙盒 Document
    #define kPathDocument [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) firstObject]
    //获取沙盒 Cache
    #define kPathCache [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) firstObject]
    
    //GCD - 一次性执行
    #define kDISPATCH_ONCE_BLOCK(onceBlock) static dispatch_once_t onceToken; dispatch_once(&onceToken, onceBlock);
    //GCD - 在Main线程上运行
    #define kDISPATCH_MAIN_THREAD(mainQueueBlock) dispatch_async(dispatch_get_main_queue(), mainQueueBlock);
    //GCD - 开启异步线程
    #define kDISPATCH_GLOBAL_QUEUE_DEFAULT(globalQueueBlock) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), globalQueueBlocl);
    
    
    #endif /* PrefixHeader_pch */
  • 相关阅读:
    Centos7:Redis3.0集群搭建
    Centos7:Redis的安装,配置及使用
    nginx 配置反向代理和负载均衡
    Centos7:nginx的安装,配置及使用
    Centos7:dubbo监控中心安装,配置和使用
    Centos7:配置防火墙
    MarkDown常用语法
    关于获取本地系统时间是正确的,但插入数据库是错的,相差8小时
    Uncaught TypeError: Cannot read property 'getters' of undefined
    java mysql连接时出现的问题
  • 原文地址:https://www.cnblogs.com/sayimba/p/6265967.html
Copyright © 2011-2022 走看看