123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- //
- // 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 ([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宏
- #define kStatusHeight (kSize.height == 812.0 ? 44 : 20)
- #define kNavOffSet (kSize.height == 812.0 ? 88 : 64)
- #define kTabBarHeight (kSize.height == 812.0 ? 83 : 49)
- #define SafeAreaBottomHeight (kSize.height == 812.0 ? 34 : 0)
- #define kSegmentHeight 44
- #define kSize [[UIScreen mainScreen]bounds].size
- #ifndef kFrame
- #define kFrame [[UIScreen mainScreen]bounds]
- #endif
- //colors
- #define defGreen [UIColor colorWithRed:35/255.0 green:160/255.0 blue:227/255.0 alpha:1]
- #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]
- //简单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
- @interface NSDictionary (Log)
- @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
|