zoukankan      html  css  js  c++  java
  • iOS

    • 以下直接复制,在此不逐条解释
    • tost框架挺好用 https://github.com/scalessec/Toast
    
    /// 回收键盘
    #define KEND_EDITING [[[UIApplication sharedApplication] keyWindow] endEditing:YES]
    
    /// 弧度转角度
    #define KRADIAN_TO_DEGREES(radian) (radian * 180.0) / (M_PI)
    
    /// 角度转弧度
    #define KDEGREES_TO_RADIAN(x)      (M_PI * (x) / 180.0)
    
    /// 对象是否为空
    #define KOBJ_IS_EMPTY(_object) (_object == nil 
      || [_object isKindOfClass:[NSNull class]] 
      || ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) 
      || ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))
    
    ///字典是否为空
    #define KDIC_IS_EMPTY(dic) (dic == nil || [dic isKindOfClass:[NSNull class]] || dic.allKeys == 0)
    
    /// 数组是否为空
    #define KARRAY_IS_EMPTY(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0)
    
    /// 字符串是否为空
    #define KSTR_IS_EMPTY(str) ([str isKindOfClass:[NSNull class]] || str == nil || [str length] < 1 ? YES : NO )
    
    //带有RGBA的颜色设置
    #define KCOLOR_RGBA(R, G, B, A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]
    #define KWHITECOLOR [UIColor whiteColor]
    #define KCLEARCOLOR [UIColor clearColor]
    #define KREDCOLOR   [UIColor redColor]
    #define KBLACKCOLOR [UIColor blackColor]
    #define KORANGECOLOR [UIColor orangeColor]
    ///图片
    #define KImageNamed(a) [UIImage imageNamed:(a)]
    /** 获取系统版本 */
    #define KDEVICE_SYSTEM_VERSION_STRING [[UIDevice currentDevice] systemVersion]
    /** 获取系统版本 */
    #define KDEVICE_SYSTEM_VERSION_FLOATVALUE  [[[UIDevice currentDevice] systemVersion] floatValue]
    
    /** 通知中心 */
    #define KNOTIFACTION_CENTER  [NSNotificationCenter defaultCenter]
    
    /** 偏好 */
    #define KUSER_DEFAULT [NSUserDefaults standardUserDefaults]
    
    /** 设备标示 */
    #define KUUID ([[[UIDevice currentDevice] identifierForVendor] UUIDString])
    
    /// 获取APP版本号
    #define KAPP_VERSION  [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
    
    /// 设置字体大小
    #define KFONT(a)      [UIFont systemFontOfSize:(a)]
    /// 设置LED字体样式
    #define KFONT_LED(a)  [UIFont fontWithName:@"Georgia-Bold" size:(a)]
    
    
    /// 获取屏幕尺寸相关
    /* 屏幕宽度 */
    #define KSCREEN_WIDTH ([UIScreen mainScreen].bounds.size.width)
    /** 屏幕高度 */
    #define KSCREEN_HEIGHT ([UIScreen mainScreen].bounds.size.height)
    /** 屏幕bounds */
    #define KSCREEN_BOUNDS ([UIScreen mainScreen].bounds)
    
    /// 打印相关
    #ifdef DEBUG
    #define KLog(format, ...) printf("
    [%s] %s [第%d行] %s
    ", __TIME__, __FUNCTION__, __LINE__, [[NSString stringWithFormat:format, ## __VA_ARGS__] UTF8String]);
    #else
    #define KLog(format, ...)
    #endif
    
    
    /// 判断屏幕尺寸
    /// 4寸
    #define KSCREEN_4INCH   (KSCREEN_WIDTH == 320 ? YES : NO)
    /// 4.7寸
    #define KSCREEN_4_7INCH (KSCREEN_WIDTH == 375 ? YES : NO)
    /// 5.5寸
    #define KSCREEN_5_5INCH (KSCREEN_WIDTH == 414 ? YES : NO)
    
    #define KVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]
    #define KUUID ([[[UIDevice currentDevice] identifierForVendor] UUIDString])
    #define KIOS_Version_FloatValue [[[UIDevice currentDevice] systemVersion] floatValue]
    #define KIOS_Version_String [[UIDevice currentDevice] systemVersion]
    #define KCurrentLanguage ([[NSLocale preferredLanguages] objectAtIndex:0])
    //定义UIImage对象
    #define KImageNamed(a) [UIImage imageNamed:(a)]
    
    #define kStringIsEmpty(str) ([str isKindOfClass:[NSNull class]] || str == nil || [str length] < 1 ? YES : NO )
    #define kArrayIsEmpty(array) (array == nil || [array isKindOfClass:[NSNull class]] || array.count == 0)
    #define kObjectIsEmpty(_object) (_object == nil 
    || [_object isKindOfClass:[NSNull class]] 
    || ([_object respondsToSelector:@selector(length)] && [(NSData *)_object length] == 0) 
    || ([_object respondsToSelector:@selector(count)] && [(NSArray *)_object count] == 0))
    
    
  • 相关阅读:
    《海思VPSS — 将1920*1080图像通过VPSS缩放旋转成800*1280在LCD上显示》
    《Shell编程实例 —— 自动检测并挂载硬盘》
    《Shell脚本学习 —— 运算符、输入/输出重定向》
    《Shell脚本学习 —— 函数、文件包含》
    《Shell脚本学习 —— 流程控制if、for、while、无限循环、until、case、跳出循环》
    《Shell脚本学习 —— Shell传递参数、echo命令、test命令》
    牛客多校第三场 A—pacm team (4维背包加路径压缩)
    牛客第二场Dmoney
    牛客第二场A-run
    牛客第二场A-run
  • 原文地址:https://www.cnblogs.com/adampei-bobo/p/7272237.html
Copyright © 2011-2022 走看看