zoukankan      html  css  js  c++  java
  • iOS 常用的方便宏定义

    //Downloader

    #define DOCUMENTS_FOLDER    [NSHomeDirectory() stringByAppendingPathComponent:@"Documents/"]

    #define kNetWorkErrorString @"网络错误"

    #define kAllDataLoaded      @"已加载完所有数据"

    #define USHARE_DEMO_APPKEY  @"59f99acf734be411fe00001e"//分享

    #define UMessage_DEMO_APPKEY  @"5a177ccab27b0a1aaa000155"//推送

    //App Constant Values

    #define kLoginUserDataFile                  @"LoginUserDataFile"

    #define kLoginInDataFile @"LoginInDataFile"

     #define D_width SCREENWIDTH/375

    #define D_height SCREENHEIGHT/667

    //正常地址

    #define k_BASE_URL(url) [NSString stringWithFormat:@"%@%@",BaseURL,url]

    #define k_BASE_ImgURL(url) [NSString stringWithFormat:@"%@%@",HeadURL,url]

    //屏幕宽高等

     #define winWidth [[UIScreen mainScreen] bounds].size.width

    #define winHeight [[UIScreen mainScreen] bounds].size.height

    #define statusHeight (winHeight == 812.0 ? 44 : 20)

    #define naviHeight (winHeight == 812.0 ? 88 : 64)

    #define tabBarHeight (winHeight == 812.0 ? 83.0f : 49.0f)

    //#define tabHeight 39

    #define safeBotHeight (winHeight == 812.0 ? 20 : 0)

    #define marginSpace 10

     //各种系统版本

    #define IOS11Later (@available(iOS 11, *))

    #define IOS10Later (@available(iOS 10, *))

    #define IOS9Later (@available(iOS 9, *))

    //取消自动缩进

    #define CancelAutoInset(scrollview) if (@available(iOS 11.0, *)) {

    scrollview.contentInsetAdjustmentBehavior = UIApplicationBackgroundFetchIntervalNever;

    } else {

    self.automaticallyAdjustsScrollViewInsets = false;

    }

    //字体

    #define Thin(num) [UIFont systemFontOfSize:num weight:UIFontWeightThin]

    #define Light(num) [UIFont systemFontOfSize:num weight:UIFontWeightLight]

    #define Regular(num) [UIFont systemFontOfSize:num weight:UIFontWeightRegular]

    #define Sbold(num) [UIFont systemFontOfSize:num weight:UIFontWeightSemibold]

    #define Bold(num) [UIFont systemFontOfSize:num weight:UIFontWeightBold]

    //从设置文件里读取当前版本号

    #define AppVersion [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]

    #define WS(weakSelf) __weak __typeof(&*self)weakSelf = self;

    //优化NSLog

    #ifdef DEBUG

    #define NSLog(format,...) printf("%s ",[[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String])

    #else

    #define NSLog(...)

    #endif

    #define WeakObj(o) @autoreleasepool{} __weak typeof(o) o##Weak = o;

    // View 圆角和加边框

    #define ViewBorderRadius(View, Radius, Width, Color)

    [View.layer setCornerRadius:(Radius)];

    [View.layer setMasksToBounds:YES];

    [View.layer setBorderWidth:(Width)];

    [View.layer setBorderColor:[Color CGColor]]

    // View 圆角

    #define ViewRadius(View, Radius)

    [View.layer setCornerRadius:(Radius)];

    [View.layer setMasksToBounds:YES]

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

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

    #define kGlobalBg RGB(240, 240, 240)

    #define kGlobalTintColor RGBColor(28, 26, 35 ,1)

    #define kBGBaseColor RGB(0, 155, 248)

    #define kNewFile RGB(0, 185, 55)

    #define kGrayTitle RGB(111, 113, 121)

    #define kOrangeColor RGB(255, 183, 51)

    #define kRedColor RGB(241, 90, 90)

    #define kBlueColor RGB(39, 140, 204)

    //3秒消失 -success

    #define SVProgressShowSuccessWithInfo(s) {[SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom]; [SVProgressHUD setBackgroundColor:BarTintColor];[SVProgressHUD setForegroundColor:WHITE];[SVProgressHUD showSuccessWithStatus:[NSString stringWithFormat:@"%@",s]];}

    //3秒消失 - info

    #define SVProgressShowInfoWithStatus(s) {[SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom]; [SVProgressHUD setBackgroundColor:BarTintColor];[SVProgressHUD setForegroundColor:WHITE];[SVProgressHUD showInfoWithStatus:[NSString stringWithFormat:@"%@",s]];}

    //不消失 - info

    #define SVProgressShowInfo(s) {[SVProgressHUD setDefaultStyle:SVProgressHUDStyleCustom];[SVProgressHUD setBackgroundColor:BarTintColor];[SVProgressHUD setForegroundColor:[UIColor whiteColor]];[SVProgressHUD setDefaultMaskType:SVProgressHUDMaskTypeCustom];[SVProgressHUD setDefaultAnimationType:SVProgressHUDAnimationTypeNative];[SVProgressHUD showWithStatus:[NSString stringWithFormat:@"%@",s]];}

    #define popNaiv   [self.navigationController popViewControllerAnimated:YES];

    #define BarTintColor  [UIColor colorWithHexString:@"373b3e"]

    #define localImg(img) [UIImage imageNamed:img]

    /**

     *  判断是否空

     */

    static inline BOOL IsEmpty(id thing) {

        return thing == nil || [thing isEqual:[NSNull null]]

        || ([thing respondsToSelector:@selector(length)]

            && [(NSData *)thing length] == 0)

        || ([thing respondsToSelector:@selector(count)]

            && [(NSArray *)thing count] == 0);

    }

  • 相关阅读:
    关于商业智能(Business Intelligence,简称BI)的认识
    Python连接mysql数据库和关闭数据库的方法
    Python 列表list方法clear( )和直接list [ ]的区别
    截止今天学习大数据技术的笔记
    【已解决】hive导出mysql报错:Container [pid=3962,containerID=container_1632883011739_0002_01_000002] is running 270113280B beyond the 'VIRTUAL' memory limit.
    sqoop安装配置以及简单使用
    大数据相关常用命令行或操作
    阿里巴巴数据库设计规范
    【已解决】linux环境jps命令不显示进程
    【已解决】初始化 Hive 元数据库报错slf4j-log4j12-1.7.25.jar包冲突
  • 原文地址:https://www.cnblogs.com/lidongxiao/p/9584917.html
Copyright © 2011-2022 走看看