• 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);

    }

  • 相关阅读:
    ExtJS专题(十):layout布局的使用(3)
    ExtJS专题(十一):lTree的Treepanel使用
    ExtJS专题(四):ExtJS组件的属性
    ExtJS专题(七):ExtJS面板Panel中视图区ViewPort的使用
    ExtJS专题(二):ExtJS类库和组件介绍
    ExtJS专题(十):layout布局的使用(1)
    EXtJS专题(九):ExtJS对话框的使用
    ExtJS专题(五):ExtJS面板Panel的使用
    ExtJS专题(三):ExtJS组件的使用
    ExtJS专题(八):ExtJS窗口Window的使用
  • 原文地址:https://www.cnblogs.com/lidongxiao/p/9584917.html
Copyright © 2020-2023  润新知