美文网首页
常用PCH文件

常用PCH文件

作者: 小苗晓雪 | 来源:发表于2017-02-13 13:24 被阅读16次
    //屏幕宽高
    #define SCREEN_WIDTH         ([UIScreen mainScreen].bounds).size.width
    #define SCREEN_HEIGHT        ([UIScreen mainScreen].bounds).size.height
    
    // iOS 系统版本
    #define IOS_VERSION       [[[UIDevice currentDevice] systemVersion] floatValue]
    
    //几种屏幕的尺寸
    #define KDevice_IS_iPhone4s ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) : NO)
    
    #define KDevice_IS_iPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) : NO)
    
    #define KDevice_IS_iPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) : NO)
    
    #define KDevice_IS_iPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) : NO)
    
    //屏幕比例
    #define KWIDTH_6PLUS_SCALE        [UIScreen mainScreen].bounds.size.width/414.0f
    #define KHEIGHT_6PLUS_SCALE       [UIScreen mainScreen].bounds.size.height/736.0f
    #define KWIDTH_IPHONE6_SCALE      [UIScreen mainScreen].bounds.size.width/375.0f
    #define KHEIGHT_IPHONE6_SCALE     [UIScreen mainScreen].bounds.size.height/667.0f
    #define KWIDTH_IPHONE5_SCALE      [UIScreen mainScreen].bounds.size.width/320.0f
    #define KHEIGHT_IPHONE5_SCALE     [UIScreen mainScreen].bounds.size.height/568.0f
    
    //NavBar高度
    #define NAVIGATION_HEIGHT_44  44
    
    //NavBar高度 + statusBar高度
    #define NAVIGATION_HEIGHT_64  64
    
    //TabBar高度
    #define TABAR_HEIGHT_49       49
    
    //常用cell高度
    #define CELLS_HEIGHT          44
    
    
    //RGB 色值 以及 alpha值
    #define RGBA(r, g, b,a)     [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
    #define RGB(r, g, b)        [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
    
    // RGB 颜色转换(16进制->10进制)
    #define RGB_VALUE(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]
    
    // NSUserDefaults
    #define USER_DEFAULT [NSUserDefaults standardUserDefaults]
    
    //字体的设置
    #define SYSTEM_FONT(f) [UIFont systemFontOfSize:f]
    #define BOLD_FONT(f)   [UIFont boldSystemFontOfSize:f]
    
    //重写Debug模式下打印日
    #ifdef DEBUG
    #define DebugLog(format, ...) printf("\n[%s] %s [第%d行] %s\n", __TIME__, __FUNCTION__, __LINE__, [[NSString stringWithFormat:format, ## __VA_ARGS__] UTF8String]);
    #else
    #define DebugLog(...)
    #endif
    
    //AppDelegate
    #define SHARE_APP ((AppDelegate *)[[UIApplication sharedApplication] delegate])
    
    //获取当前的类
    #define CURRENT_ClASS  NSStringFromClass([self class]
    
    //弱引用
    #define weakSelf(weakSelf) __weak __typeof(&*self)weakSelf = self;
    
    #endif /* App_pch */
    
    

    愿编程让这个世界更美好

    相关文章

      网友评论

          本文标题:常用PCH文件

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