MZExtension 2.2.2

MZExtension 2.2.2

MZ维护。



  • 作者:
  • MZ

MZExtension

OC的扩展

自定义控件(扩展)

1、MZBannerView(广告轮播)

2、MZCircleProgress(圆形倒计时)

3、MZMarqueeLabel(滚动字符串)

4、MZMobileField(手机号码格式化)

5、MZTableView(水平tableView)

6、MZTextField(文本框字符串长度限制)

7、MZTextView(文本视图字符串长度限制和placeholder设置)

8、MZWaveView(双波浪视图)

9、MZImageBrowsing(图片浏览器)

10、MZAlertController(半透明控制器,类似于UIAlertController功能)

11、MZDrawBoardView(使用CAShapeLayer实现画板功能,可在画板上书写和绘画)

12、MZLongTapButton(长按按钮)

自定义类别

1、NSDictionary+MZTool

  1. 从字典中获取一个字典
  • -(NSDictionary *)dictionaryForKey:(NSString *)key;
  1. 从字典中获取一个数组
  • -(NSArray *)arrayForKey:(NSString *)key;
  1. 从字典中获取一个字符串
  • -(NSString *)stringForKey:(NSString *)key;
  1. 从字典中获取一个布尔值
  • -(BOOL)boolForKey:(NSString *)key;
  1. 从字典中获取一个整型数字
  • -(NSInteger)intForKey:(NSString *)key;
  1. 从字典中获取一个双精度型数字
  • -(double)doubleForKey:(NSString *)key;

2、UIImage+MZTool

  1. 根据颜色生成图片
  • +(UIImage *)getImageWithColor:(UIColor *)color;
  1. 根据字符串和二维码图片大小生成二维码图片
  • +(UIImage *)createBarCodeImageWithString:(NSString *)string size:(CGFloat)size;
  1. 根据颜色的渐变色获取图片
  • +(UIImage *)createImageWithFrame:(CGRect)frame startColor:(UIColor *)startColor endColor:(UIColor *)endColor startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint;
  1. base64字符串转图片
  • +(UIImage *)stringToImage:(NSString *)base64String;
  1. 图片转base64字符串
  • -(NSString *)imageToBase64String;
  1. 截取视图成图片
  • +(UIImage *)clipsImage:(UIView *)view;
  1. 对图片进行剪切,获取指定范围的图片
  • +(UIImage *)clipsImage:(UIImage *)image frame:(CGRect)frame;
  1. 生成指定大小图片
  • +(UIImage *)resizeImage:(UIImage *)image toSize:(CGSize)size;
  1. 生成圆形图片
  • +(UIImage *)cutCircleImage:(UIImage *)image;
  1. 生成部分圆形图片
  • +(UIImage *)cutPartCircleImage:(UIImage *)image corners:(UIRectCorner)corners radii:(CGSize)radii;
  1. 处理图片旋转问题
  • +(UIImage *)fixOrientation:(UIImage *)aImage;

3、UIView+MZTool

  1. 设置视图背景颜色的渐变色
  • -(void)setupGradientColorWithStartColor:(UIColor *)startColor endColor:(UIColor *)endColor startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint;
  1. 给视图添加点击事件
  • -(void)addTapGestureRecognizerWithTarget:(id)target selector:(SEL)selector;
  1. 根据一个VC上的视图获取该VC
  • -(UIViewController *)getVC;
  1. 设置视图圆角
  • -(void)setRadius:(CGFloat)radius;
  1. 设置部分圆角
  • -(void)setRoundedCorners:(UIRectCorner)corners radii:(CGSize)radii;

4、NSObject+MZTool

  1. 获取当前显示的ViewController
  • +(UIViewController *)currentViewController;
  1. 获取屏幕窗口
  • +(UIView *)getWindowView;
  1. 获取手机当前连接的SSID(iOS12后要开启capabilities中的Access WiFi Information)
  • +(NSString *)SSID;
  1. 获取app版本号
  • +(NSString *)getAppVersion;
  1. 获取app Build
  • +(NSString *)getAppBuild;
  1. 获取app名称
  • +(NSString *)getAppName;
  1. 获取app BundleID
  • +(NSString *)getAppBundleIdentifier;
  1. 获取app Icon
  • +(UIImage *)getAppIcon;

5、NSString+MZTool

  1. 字符串MD5加密
  • -(NSString *)MD5;
  1. 普通字符串转换为十六进制字符串
  • +(NSString *)hexStringFromString:(NSString *)string;
  1. 十六进制字符串转换为普通字符串
  • +(NSString *)stringFromHexString:(NSString *)hexString;
  1. data转换为十六进制字符串
  • +(NSString *)dataToHexString:(NSData *)data;
  1. 转换为本地大端模式,返回无符号类型的数据
  • +(unsigned short)unsignedDataTointWithData:(NSData *)data Location:(NSInteger)location Offset:(NSInteger)offset;

6、UIViewController+MZAlert

  1. 系统提示框(确认按钮在左,取消按钮在右)
  • -(void)showAlertWithTitle:(NSString *)title message:(NSString *)message confirmTitle:(NSString *)confirmTitle cancelTitle:(NSString *)cancelTitle confirm:(void(^)(void))confirm cancel:(void(^)(void))cancel;
  1. 系统提示款(确认按钮在右,取消按钮在左)
  • -(void)showAlertWithTitle:(NSString *)title message:(NSString *)message cancelTitle:(NSString *)cancelTitle confirmTitle:(NSString *)confirmTitle confirm:(void(*)(void))confirm cancel:(void(*)(void))cancel;
  1. 系统提示款(只有一个按钮)
  • -(void)showAlertWithTitle:(NSString *)title message:(NSString *)message confirmTitle:(NSString *)confirmTitle confirm:(void (^)(void))confirm;
  1. 系统提示框(自定义标题和内容)
  • -(void)showAlertWithAttributedTitle:(NSAttributedString *)attributedTitle attributedMessage:(NSAttributedString *)attributedMessage confirmTitle:(NSString *)confirmTitle confirmStyle:(UIAlertActionStyle)confirmStyle cancelTitle:(NSString *)cancelTitle cancelStyle:(UIAlertActionStyle)cancelStyle confirm:(void(^)(void))confirm cancel:(void(*)(void))cancel;
  1. 系统提示框(自定义标题和内容以及按钮标题颜色)
  • -(void)showAlertWithAttributedTitle:(NSAttributedString *)attributedTitle attributedMessage:(NSAttributedString *)attributedMessage confirmTitle:(NSString *)confirmTitle confirmColor:(UIColor *)confirmColor cancelTitle:(NSString *)cancelTitle cancelColor:(UIColor *)cancelColor confirm:(void(*)(void))confirm cancel:(void(*)(void))cancel;
  1. 系统操作框
  • -(void)showActionSheetWithTitle:(NSString *)title message:(NSString *)message actionTitles:(NSArray *)actionTitles cancelTitle:(NSString *)cancelTitle cancelColor:(UIColor *)cancelColor callback:(void(^)(NSString *actionTitle))callback;
  1. 系统操作框(自定义标题和内容以及按钮标题颜色)
  • -(void)showActionSheetWithAttributedTitle:(NSAttributedString *)attributedTitle attributedMessage:(NSAttributedString *)attributedMessage actionTitles:(NSArray *)actionTitles actionColors:(NSArray *)actionColors cancelTitle:(NSString *)cancelTitle cancelColor:(UIColor *)cancelColor callback:(void(^)(NSString *actionTitle))callback;

7、NSObject+MZDate

  1. 时间转字符串
  • +(NSString *)dateToStringWithDate:(NSDate *)date dateFormat:(NSString *)dateFormat;
  1. 字符串转时间
  • +(NSDate *)stringToDateWithString:(NSString *)string dateFormat:(NSString *)dateFormat;
  1. 间戳转字符串
  • +(NSString *)timeIntervalToStringWithTimeInterval:(NSTimeInterval)timeInterval dateFormat:(NSString *)dateFormat;
  1. 字符串转时间戳
  • +(NSTimeInterval)stringToTimeIntervalWithString:(NSString *)string dateFormat:(NSString *)dateFormat;
  1. 时间戳转特殊字符串(如果是今明两天,会将月日转换成“今天”或“明天”)
  • +(NSString *)specialTimeIntervalToStringWithTimeInterval:(NSTimeInterval)timeInterval dateFormat:(NSString *)dateFormat;
  1. 获取当前时间戳
  • +(NSTimeInterval)getNowTimeInterval;

8、UIButton+MZTouch

  1. 通过eventTimeInterval来设置UIButton点击间隔

9、NSArray+MZTool

  1. 获取数组中的最大值数组
  • -(void)caculateMaxArray:(void(^)(NSArray *maxArray,NSInteger startIndex,NSInteger endIndex))callback;

10、UIColor+MZTool

  1. 获取图片上某个点的颜色
  • +(UIColor *)colorAtPixel:(CGPoint)point withImage:(UIImage *)image;
  1. 根据16进制字符串获取颜色
  • +(UIColor *)colorWithHexString:(NSString *)hexString;

11、UIView+MZFrame

  • @property (nonatomic, assign) CGFloat mz_x;
  • @property (nonatomic, assign) CGFloat mz_y;
  • @property (nonatomic, assign) CGFloat mz_width;
  • @property (nonatomic, assign) CGFloat mz_height;
  • @property (nonatomic, assign) CGFloat mz_centerX;
  • @property (nonatomic, assign) CGFloat mz_centerY;

12、NSObject+MZAvoidCrash

  1. 统一处理找不到对应方法崩溃的问题
  2. 统一处理键值对编码找不到对应属性崩溃的问题

13、NSArray+MZLog

  1. 统一处理数组打印的问题

14、NSDictionary+MZLog

  1. 统一处理字典打印的问题

15、NSArray+MZTool

  1. 获取数组中的最大值数组
    • (void)caculateMaxArray:(void(^)(NSArray *maxArray,NSInteger startIndex,NSInteger endIndex))callback;