美文网首页
iOS 常用的方便宏定义

iOS 常用的方便宏定义

作者: 以前十八 | 来源:发表于2022-03-19 03:20 被阅读0次

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\n",[[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);

}

相关文章

  • iOS 常用的方便宏定义

    iOS 常用的方便宏定义[https://www.cnblogs.com/lidongxiao/p/9584917...

  • iOS常用宏定义

    打印日志的几种写法 推荐文章iOS 日常工作之常用宏定义大全iOS常用宏定义 结束语 到这里就结束了,如若不懂的话...

  • iOS-常用宏定义

    [转自:iOS常用宏定义][http://www.cocoachina.com/ios/20161207/1831...

  • iOS 常用宏定义

    iOS 开发中使用一些常用宏定义可以大大提高开发效率,提高代码的重用性.以下是一些常用的宏定义: 像这些宏定义,在...

  • IOS NSLog宏定义

    IOS NSLog宏定义 标签(空格分隔): IOS IOS NSLog宏定义 宏定义NSLog方法,不用加";"...

  • iOS常用宏定义

    1.UI元素 //NavBar高度#defineNAVIGATIONBAR_HEIGHT 44//StatusBa...

  • iOS常用宏定义

    字符串是否为空 #define kStringIsEmpty(str) ([str isKindOfClass:[...

  • iOS常用宏定义

    字符串是否为空 数组是否为空 字典是否为空 是否是空对象 获取屏幕宽度与高度 ( " \ ":连接行标志,连接上下...

  • iOS常用宏定义

  • iOS常用宏定义

    #ifndef MacroDefinition_h #define MacroDefinition_h //---...

网友评论

      本文标题:iOS 常用的方便宏定义

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