// // UIFormatter.h // test11 // // Created by apple on 15/11/13. // Copyright (c) 2016年 JCZ. All rights reserved. // #import #import /** 这里貌似有2个高度。1种是屏幕高度。1种是被导航栏偏移减少后的高度 */ #define kSize [[UIScreen mainScreen]bounds].size #ifndef kFrame #define kFrame [[UIScreen mainScreen]bounds] #endif #pragma mark - UI宏 //判断是否是ipad #define RQ_isPad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) //判断iPhone4系列 #define kiPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) && !RQ_isPad : NO) //判断iPhone5系列 #define kiPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) && !RQ_isPad : NO) //判断iPhone6系列 #define kiPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) && !RQ_isPad : NO) //判断iphone6+系列 #define kiPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) || CGSizeEqualToSize(CGSizeMake(1080, 1920), [[UIScreen mainScreen] currentMode].size) && !RQ_isPad : NO) //判断iPhoneX #define IS_IPHONE_X ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !RQ_isPad : NO) //判断iPHoneXr #define IS_IPHONE_Xr ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? (CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) || CGSizeEqualToSize(CGSizeMake(750, 1624), [[UIScreen mainScreen] currentMode].size)) && !RQ_isPad : NO) //判断iPhoneXs #define IS_IPHONE_Xs ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !RQ_isPad : NO) //判断iPhoneXs Max #define IS_IPHONE_Xs_Max ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) && !RQ_isPad : NO) //判断iPhone12_Mini #define IS_IPHONE_iPhone12_Mini ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1080, 2340), [[UIScreen mainScreen] currentMode].size) && !RQ_isPad : NO) //判断iPhone12 | 12Pro #define IS_IPHONE_iPhone12 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1170, 2532), [[UIScreen mainScreen] currentMode].size) && !RQ_isPad : NO) //判断iPhone12 Pro Max #define IS_IPHONE_iPhone12_ProMax ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1284, 2778), [[UIScreen mainScreen] currentMode].size) && !RQ_isPad : NO) //x系列 #define IS_IPHONE_IPhoneX_All (IS_IPHONE_X || IS_IPHONE_Xr || IS_IPHONE_Xs || IS_IPHONE_Xs_Max || IS_IPHONE_iPhone12_Mini || IS_IPHONE_iPhone12 || IS_IPHONE_iPhone12_ProMax) #define KScreenSize [UIScreen mainScreen].bounds.size #define KScreenwidth [UIScreen mainScreen].bounds.size.width #define KScreenheight [UIScreen mainScreen].bounds.size.height //#define kFrame [[UIScreen mainScreen]bounds] //#define kSize [[UIScreen mainScreen]bounds].size #define kCellBd 1 #define kCellW (kSize.width - 2*kCellBd)/3.0 #define kCellH (kCellW - kCellBd)/2.0 #define kSecHeadHeight 10 //75 #define kNavBarHeight 44 #define kSegmenHeight 51 #define kLeftViewWid kSize.width * 0.87 #define kTabBarHeight (IS_IPHONE_IPhoneX_All ? 83.0 : 49.0) #define kStatusHeight (IS_IPHONE_IPhoneX_All ? 44.0 : 20.0) #define kNavOffSet ((IS_IPHONE_Xr == YES || IS_IPHONE_Xs == YES || IS_IPHONE_Xs_Max == YES || IS_IPHONE_iPhone12_Mini == YES) ? 88.0 : (IS_IPHONE_X == YES) ? 92 : (IS_IPHONE_iPhone12 == YES || IS_IPHONE_iPhone12_ProMax == YES) ? 91 : 64.0) #define kSafeAreaBottomHeight (IS_IPHONE_IPhoneX_All ? 34 : 0) #define defaultImg [UIImage imageNamed:@"subject2_standart_icon.png"] #define navBarColor [UIColor colorWithLightColorStr:@"FFFFFF" DarkColor:@"000000"] #define backGroundColor [UIColor colorWithLightColorStr:@"FFFFFF" DarkColor:@"181818"] #define selectedBackGroundColor [UIColor colorWithLightColorStr:@"F6F6F6" DarkColor:@"303030"] #define windowBlockColor [UIColor colorWithWhite:.2 alpha:.2] #define RQlineColor [UIColor colorWithLightColorStr:@"EFEFF4" DarkColor:@"000000"] #define kTitleColor [UIColor colorWithLightColorStr:@"464646" DarkColor:@"F7F7F7"] #define subTitleColor [UIColor colorWithLightColorStr:@"787878" DarkColor:@"F7F7F7"] #define contentTextColor [UIColor colorWithLightColorStr:@"6E6E6E" DarkColor:@"F7F7F7"] #define RGBA_COLOR(R, G, B, A) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:A] #define RGB_COLOR(R, G, B) [UIColor colorWithRed:((R) / 255.0f) green:((G) / 255.0f) blue:((B) / 255.0f) alpha:1.0f] //测试服的图片地址 #define imgPreTest @"http://218.6.66.181:9999/doc/" //正式服的图片地址 #define imgPreFix @"http://fj.jppt.com.cn/doc/" #define kBgColor 0.95 #define largeFont [UIFont scaleSize:20 weight:10] #define midFont [UIFont scaleSize:14 weight:5] #define smallFont [UIFont scaleSize:10 weight:4] //简单setFrame #define setxywh initWithFrame:CGRectMake(x, y, w, h) #define setDIYFrame CGRectMake(x, y, w, h) #define FontLarger 21 #define FontTitle 18 #define Font17 17 #define Font16 16 #define NormalFont 15 #define Font13 13 #define SmallFont 10 /// 适配iPhone X + iOS 11 #define RQAdjustsScrollViewInsets_Never(__scrollView)\ do {\ _Pragma("clang diagnostic push")\ _Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"")\ if ([__scrollView respondsToSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:")]) {\ NSMethodSignature *signature = [UIScrollView instanceMethodSignatureForSelector:@selector(setContentInsetAdjustmentBehavior:)];\ NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:signature];\ NSInteger argument = 2;\ invocation.target = __scrollView;\ invocation.selector = @selector(setContentInsetAdjustmentBehavior:);\ [invocation setArgument:&argument atIndex:2];\ [invocation retainArguments];\ [invocation invoke];\ }\ _Pragma("clang diagnostic pop")\ } while (0) #define unOpenMsg @"暂未开放,敬请期待" /**自动屏幕适配,把屏幕当成320*480来写就行了。 该方法不适用于动画 */ CGRect SGRectMake(CGFloat x, CGFloat y,CGFloat width,CGFloat height); /**自动屏幕适配基础上,固定frame的height不进行适配 */ //CGRect SGRectMakeCH(CGFloat x, CGFloat y,CGFloat width,CGFloat height); /**自动屏幕适配基础上,固定frame的y不进行适配 */ //CGRect SGRectMakeCY(CGFloat x, CGFloat y,CGFloat width,CGFloat height); /**自动屏幕适配基础上,固定frame的y,heigh不进行适配 */ CGRect SGRectMakeCYH(CGFloat x, CGFloat y,CGFloat width,CGFloat height); CGSize SGSizeMake(CGFloat width,CGFloat height); /**自动屏幕适配的竖向float */ CGFloat SGFloat(CGFloat k); @interface UIFormatter : NSObject @end @interface UIViewController(Navigation) /**通用导航栏,设置好leftBBI,及其事件 */ -(void)configNavigationBar; /**通过导航栏返回上级菜单 */ //回到导航控制器的首页 -(void)configNavigationBarFirstVC; /** 这个是把nav给Dismiss掉 */ -(void)configNavigationBarDismissNav; /**隐藏导航栏 */ -(void)navPushHideTabbarToVC:(UIViewController*)vc; /**这个是隐藏返回按钮的.主要是给搜教练VC用的。因为,它要禁止返回。 */ -(void)configNavigationBarHideLeft; /**返回直接跳转到rootVC */ -(void)configNavigationBarPopRoot; @end @interface UIView(formatter) -(void)setRound; - (void)setBoardWid:(CGFloat)width Color:(UIColor*)color CornerRadius:(NSInteger)cornerRadius; /**注意:这个headerView是添加到self的superview里面去的。 */ -(void)addViewWithRect:(CGRect)re Color:(UIColor*)color; -(void)addViewWithRect:(CGRect)re; /**这个是加到self。 */ -(void)addSelfViewWithRect:(CGRect)re Color:(UIColor*)color; -(void)scale:(CGFloat)rate; @end @interface UIImage (Extension) /**生成的图片的rect默认为100,100 */ + (UIImage *)imageWithColor:(UIColor *)color; @end @interface UIImage(tint) -(UIImage*)tint:(UIColor*)color; @end @interface UIImage (scale) -(UIImage*)originImageScaleToSize:(CGSize)size; @end @interface UIFont(scale) /**以6plus为基准。屏幕越小,字体越小 */ +(id)scaleSize:(CGFloat)font; @end @interface UILabel(formatter) -(void)setFont:(CGFloat)font TextColor:(UIColor*)color; -(void)setText:(NSString*)text Font:(CGFloat)font TextColor:(UIColor*)color; -(void)setText:(NSString*)text Font:(CGFloat)font TextColor:(UIColor*)color Alignment:(NSTextAlignment)align; @end UIImage* randomPortrait(void); UIColor * randomColor(void); void setRandomColor(UIView* vi);