123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252 |
- //
- // UI_Formatter&Function.h
- // LN_School
- //
- // Created by apple on 2017/4/5.
- // Copyright © 2017年 Danson. All rights reserved.
- //
- #import <Foundation/Foundation.h>
- #import <UIKit/UIKit.h>
- //版本判定
- #define iOS8 ([UIDevice currentDevice].systemVersion.floatValue >= 8.0f)
- #define iOS10 ([UIDevice currentDevice].systemVersion.floatValue >= 10.0f)
- #define IOS11 @available(iOS 11.0, *)
- #define kDevice_Is_iPhoneX [Tools isIPhoneX]
- //#define kDevice_Is_iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125,2436), [[UIScreen mainScreen] currentMode].size) : NO)
- #pragma mark QiNiu_IMSDK
- #define kScreenWidth [[UIScreen mainScreen] bounds].size.width
- //#define kScreenHeight [[UIScreen mainScreen] bounds].size.height
- #define kMainCellColor [UIColor colorWithRed:248/255.0 green:248/255.0 blue:255/255.0 alpha:1]
- #define kInputViewHeight 50
- #pragma mark - UI宏
- //判断是否是ipad
- #define kIsPad ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
- //判断iPhone4系列
- #define kiPhone4 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 960), [[UIScreen mainScreen] currentMode].size) && !kIsPad : NO)
- //判断iPhone5系列
- #define kiPhone5 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640, 1136), [[UIScreen mainScreen] currentMode].size) && !kIsPad : NO)
- //判断iPhone6系列
- #define kiPhone6 ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(750, 1334), [[UIScreen mainScreen] currentMode].size) && !kIsPad : NO)
- //判断iphone6+系列
- #define kiPhone6Plus ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2208), [[UIScreen mainScreen] currentMode].size) && !kIsPad : NO)
- //判断iPhoneX
- #define IS_IPHONE_X ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !kIsPad : NO)
- //判断iPHoneXr
- #define IS_IPHONE_Xr ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(828, 1792), [[UIScreen mainScreen] currentMode].size) && !kIsPad : NO)
- //判断iPhoneXs
- #define IS_IPHONE_Xs ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) && !kIsPad : NO)
- //判断iPhoneXs Max
- #define IS_IPHONE_Xs_Max ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1242, 2688), [[UIScreen mainScreen] currentMode].size) && !kIsPad : NO)
- //#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 44
- #define kLeftViewWid kSize.width * 0.8
- #define kTabBarHeight ((IS_IPHONE_X==YES || IS_IPHONE_Xr ==YES || IS_IPHONE_Xs== YES || IS_IPHONE_Xs_Max== YES) ? 83.0 : 49.0)
- #define kStatusHeight ((IS_IPHONE_X==YES || IS_IPHONE_Xr ==YES || IS_IPHONE_Xs== YES || IS_IPHONE_Xs_Max== YES) ? 44.0 : 20.0)
- #define kNavOffSet ((IS_IPHONE_X==YES || IS_IPHONE_Xr ==YES || IS_IPHONE_Xs== YES || IS_IPHONE_Xs_Max== YES) ? 88.0 : 64.0)
- #define kSafeAreaBottomHeight ((IS_IPHONE_X==YES || IS_IPHONE_Xr ==YES || IS_IPHONE_Xs== YES || IS_IPHONE_Xs_Max== YES) ? 34 : 0)
- #define kSize [[UIScreen mainScreen]bounds].size
- #ifndef kFrame
- #define kFrame [[UIScreen mainScreen]bounds]
- #endif
- //colors
- #define RQMianColor RQColorFromHexString(@"5375c9")
- #define RQSubColor RQColorFromHexString(@"3faeff")
- #define RQTitleTextColor RQColorFromHexString(@"787878")
- #define RQContentTextColor RQColorFromHexString(@"2f2f2f")
- #define RQPinkBlueColor RQColorFromHexString(@"5c87f8")
- #define RQPinkGreenColor RQColorFromHexString(@"0ab2a0")
- #define RQGreenColor RQColorFromHexString(@"00d08a")
- #define RQOrangeColor RQColorFromHexString(@"f48f37")
- #define RQRedColor RQColorFromHexString(@"f96060")
- #define RQBackGroundColor RQColorFromHexString(@"f6f7fb")
- #define KBackGroundColor [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1]
- #define windowBlockColor [UIColor colorWithWhite:.2 alpha:.2]
- #define kLineColor [UIColor colorWithWhite:.3 alpha:.1]
- #define KTitleColor [UIColor colorWithRed:70/255.0 green:70/255.0 blue:70/255.0 alpha:1]
- #define KSubTitleColor [UIColor colorWithWhite:.3 alpha:1]
- #define KContentTextColor [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]
- /// 根据hex 获取颜色
- #define RQColorFromHexString(__hexString__) ([UIColor colorFromHexString:__hexString__])
- //简单setFrame
- #define KSetxywh initWithFrame:CGRectMake(x, y, w, h)
- #define KSetDIYFrame 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
- @interface UI_Formatter_Function : NSObject
- @end
- #pragma mark 字体
- @interface UIFont(scale)
- /**以414为基准。屏幕越小,字体越小
- */
- +(id)scaleSize:(CGFloat)font;
- @end
- #pragma NSNumber 转字符串
- @interface NSNumber (formatter)
- + (NSString *)stringValue;
- @end
- #pragma mark UIButton
- @interface UIButton(formatter)
- - (void) setImage:(UIImage *)image withTitle:(NSString *)title textColor:(UIColor*)color Font:(CGFloat)font forState:(UIControlState)stateType;
- -(void) setTitle:(NSString*)title textColor:(UIColor*)color font:(CGFloat)font fotState:(UIControlState)stateType;
- /**简化按钮事件添加 要实现btnClick;
- */
- -(void)target:(id)obj;
- -(void)target:(id)obj Tag:(NSInteger)tag;
- -(void)setTitleNormal:(NSString*)title;
- -(void)setTitleSelect:(NSString*)title;
- @end
- #pragma mark UILabel
- @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
- #pragma mark UIImageView
- @interface UIImageView(formatter)
- /**等比缩小 适应imgV大小 裁剪超出部分
- */
- - (void)setModeAspectFill;
- @end
- #pragma mark UIImage
- @interface UIImage(formatter)
- - (UIImage*)scaledToWid:(CGFloat)wid;
- - (UIImage*)originImageScaleToSize:(CGSize)size;
- - (UIImage*)tint:(UIColor*)color;
- /**生成新尺寸 不裁剪图片
- */
- - (UIImage *)scaledToSize:(CGSize)newSize;
- /**生成新尺寸 裁剪图片
- */
- - (UIImage *)scaledAndCutToSize:(CGSize)newSize;
- @end
- #pragma mark NSString
- #import <CommonCrypto/CommonDigest.h>
- @interface NSString (ex)
- //MD5 加密
- - (NSString *)md5Encrypt;
- /**把分钟数转化为 0小时0分钟 格式
- */
- -(NSString*)hourAndmm;
- /**固定宽度,和字体大小。返回高度
- */
- -(CGFloat)heightForWid:(CGFloat)wid Font:(CGFloat)fontSize;
- /** 返回一行文字宽度
- */
- //-(CGFloat)widthForFont:(CGFloat)fontSize;
- -(CGSize)sizeForFont:(CGFloat)fontSize;
- @end
- #pragma mark NSArray
- @interface NSArray (formatter)
- - (id)h_safeObjectAtIndex:(NSUInteger)index;
- @end
- @interface UIViewController(Navigation)
- /**navPush隐藏底部导航栏
- */
- -(void)navPushHideTabbarToVC:(UIViewController*)vc;
- /**pop回去 通过导航栏返回上级菜单
- */
- -(void)goBackByNavigation;
- //回到导航控制器的首页
- -(void)goBackFirstVCByNavigation;
- /**把nav给Dismiss掉
- */
- -(void)goBackByNavDismiss;
- /**返回直接跳转到rootVC
- */
- -(void)configNavigationBarPopRoot;
- @end
|