// // UIFormatter.h // test11 // // Created by apple on 15/11/13. // Copyright (c) 2016年 JCZ. All rights reserved. // #import #import #import "UIImage+resize.h" #import "UIButton+formatter.h" #import "UIView+Frame.h" #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 kSegmentHeight 44 #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 kSize [[UIScreen mainScreen]bounds].size #ifndef kFrame #define kFrame [[UIScreen mainScreen]bounds] #endif //colors #define newBackGroundColor [UIColor colorWithRed:75/255.0 green:85/255.0 blue:132/255.0 alpha:1] #define newTitleColor [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1] #define newSubTitleColor [UIColor colorWithRed:200/255.0 green:200/255.0 blue:200/255.0 alpha:1] #define newContentTextColor [UIColor colorWithRed:150/255.0 green:150/255.0 blue:150/255.0 alpha:1] #define canClickColor [UIColor colorWithRed:134/255.0 green:204/255.0 blue:71/255.0 alpha:1] #define defGreen [UIColor colorWithRed:253/255.0 green:137/255.0 blue:38/255.0 alpha:1] #define backGroundColor [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1] #define stateBarColor [UIColor colorWithRed:22/255.0 green:90/255.0 blue:140/255.0 alpha:1] #define windowBlockColor [UIColor colorWithWhite:.2 alpha:.2] #define lineColor [UIColor colorWithWhite:.3 alpha:.1] #define kTitleColor [UIColor colorWithRed:70/255.0 green:70/255.0 blue:70/255.0 alpha:1] #define subTitleColor [UIColor colorWithWhite:.3 alpha:1] #define contentTextColor [UIColor colorWithRed:110/255.0 green:110/255.0 blue:110/255.0 alpha:1] #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] //简单setFrame #define setxywh initWithFrame:CGRectMake(x, y, w, h) #define setDIYFrame CGRectMake(x, y, w, h) //字体 #define largeFont [UIFont scaleSize:20 weight:10] #define midFont [UIFont scaleSize:14 weight:5] #define smallFont [UIFont scaleSize:10 weight:4] #define Font21 21 #define Font18 18 #define Font17 17 #define Font16 16 #define Font14 14 #define Font10 10 #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; // // ///**隐藏导航栏 // */ //-(void)navPushHideTabbarToVC:(UIViewController*)vc; ///**这个是隐藏返回按钮的.主要是给搜教练VC用的。因为,它要禁止返回。 // */ //-(void)configNavigationBarHideLeft; ///**返回直接跳转到rootVC // */ //-(void)configNavigationBarPopRoot; // //@end @interface UIView(formatter) -(void)setRound; -(void)setBoardWid:(CGFloat)width Color:(UIColor*)color; /**注意:这个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(); UIColor * randomColor(); void setRandomColor(UIView* vi);