A extension for OC
自定义控件(Extends)
1、MZBannerView(广告轮播)
2、MZCircleProgress(圆形倒计时)
3、MZMarqueeLabel(滚动字符串)
4、MZMobileField(手机号码344格式)
5、MZTableView(横向tableView)
6、MZTextField(textField字符串长度限制)
7、MZTextView(textView字符串长度限制和placeholder设置)
8、MZWaveView(双波浪试图)
9、MZImageBrowsing(图片浏览器)
10、MZAlertController(半透明控制器,类似UIAlertController功能)
11、MZDrawBoardView(CAShapeLayer实现画板功能,可在画板上写字绘画)
12、MZLongTapButton(长按按钮)
自定义类别
1、NSDictionary+MZTool
- 从字典中取出一个字典
- -(NSDictionary *)dictionaryForKey:(NSString *)key;
- 从字典中取出一个数组
- -(NSArray *)arrayForKey:(NSString *)key;
- 从字典中取出一个字符串
- -(NSString *)stringForKey:(NSString *)key;
- 从字典中取出一个布尔值
- -(BOOL)boolForKey:(NSString *)key;
- 从字典中取出一个整型数字
- -(NSInteger)intForKey:(NSString *)key;
- 从字典中取出一个双精度型数字
- -(double)doubleForKey:(NSString *)key;
2、UIImage+MZTool
- 根据颜色生成图片
- +(UIImage *)getImageWithColor:(UIColor *)color;
- 根据字符串和二维码图片大小来生成二维码图片
- +(UIImage *)createBarCodeImageWithString:(NSString *)string size:(CGFloat)size;
- 根据颜色的渐变色获取图片
- +(UIImage *)createImageWithFrame:(CGRect)frame startColor:(UIColor *)startColor endColor:(UIColor *)endColor startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint;
- base64字符串转图片
- +(UIImage *)stringToImage:(NSString *)base64String;
- 图片转base64字符串
- -(NSString *)imageToBase64String;
- 截取view成图片
- +(UIImage *)clipsImage:(UIView *)view;
- 对图片进行剪切,获取指定范围的图片
- +(UIImage *)clipsImage:(UIImage *)image frame:(CGRect)frame;
- 新生成指定大小图片
- +(UIImage *)resizeImage:(UIImage *)image toSize:(CGSize)size;
- 生成圆形图片
- +(UIImage *)cutCircleImage:(UIImage *)image;
- 生成部分圆角图片
- +(UIImage *)cutPartCircleImage:(UIImage *)image corners:(UIRectCorner)corners radii:(CGSize)radii;
- 处理图片旋转问题
- +(UIImage *)fixOrientation:(UIImage *)aImage;
3、UIView+MZTool
- 设置试图背景颜色的渐变色
- -(void)setupGradientColorWithStartColor:(UIColor *)startColor endColor:(UIColor *)endColor startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint;
- 给view添加点击事件
- -(void)addTapGestureRecognizerWithTarget:(id)target selector:(SEL)selector;
- 根据一个VC上的view得到该VC
- -(UIViewController *)getVC;
- 设置试图圆角
- -(void)setRadius:(CGFloat)radius;
- 设置部分圆角
- -(void)setRoundedCorners:(UIRectCorner)corners radii:(CGSize)radii;
4、NSObject+MZTool
- 获取当前显示的ViewController
- +(UIViewController *)currentViewController;
- 获取屏幕窗口
- +(UIView *)getWindowView;
- 获取手机当前连接的SSID(iOS12后要开启capabilities中的Access WiFi Information)
- +(NSString *)SSID;
- 获取app版本号
- +(NSString *)getAppVersion;
- 获取app Build
- +(NSString *)getAppBuild;
- 获取app名称
- +(NSString *)getAppName;
- 获取app BundleID
- +(NSString *)getAppBundleIdentifier;
- 获取app Icon
- +(UIImage *)getAppIcon;
5、NSString+MZTool
- 字符串MD5加密
- -(NSString *)MD5;
- 普通字符串转换成十六进制字符串
- +(NSString *)hexStringFromString:(NSString *)string;
- 十六进制字符串转换成普通字符串
- +(NSString *)stringFromHexString:(NSString *)hexString;
- data转16进制字符串
- +(NSString *)dataToHexString:(NSData *)data;
- 转为本地大端模式 返回Unsigned类型的数据
- +(unsigned short)unsignedDataTointWithData:(NSData *)data Location:(NSInteger)location Offset:(NSInteger)offset;
6、UIViewController+MZAlert
- 系统提示框(确认按钮在左,取消按钮在右)
- -(void)showAlertWithTitle:(NSString *)title message:(NSString *)message confirmTitle:(NSString *)confirmTitle cancelTitle:(NSString *)cancelTitle confirm:(void(^)(void))confirm cancel:(void(^)(void))cancel;
- 系统提示款(确认按钮在右,取消按钮在左)
- -(void)showAlertWithTitle:(NSString *)title message:(NSString *)message cancelTitle:(NSString *)cancelTitle confirmTitle:(NSString *)confirmTitle confirm:(void(^)(void))confirm cancel:(void(^)(void))cancel;
- 系统提示款(只有一个按钮)
- -(void)showAlertWithTitle:(NSString *)title message:(NSString *)message confirmTitle:(NSString *)confirmTitle confirm:(void (^)(void))confirm;
- 系统提示框(自定义标题和内容)
- -(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;
- 系统提示框(自定义标题和内容以及按钮标题颜色)
- -(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;
- 系统操作框
- -(void)showActionSheetWithTitle:(NSString *)title message:(NSString *)message actionTitles:(NSArray<NSString *> *)actionTitles cancelTitle:(NSString *)cancelTitle cancelColor:(UIColor *)cancelColor callback:(void(^)(NSString *actionTitle))callback;
- 系统操作框(自定义标题和内容以及按钮标题颜色)
- -(void)showActionSheetWithAttributedTitle:(NSAttributedString *)attributedTitle attributedMessage:(NSAttributedString *)attributedMessage actionTitles:(NSArray<NSString *> *)actionTitles actionColors:(NSArray<UIColor *> *)actionColors cancelTitle:(NSString *)cancelTitle cancelColor:(UIColor *)cancelColor callback:(void(^)(NSString *actionTitle))callback;
7、NSObject+MZDate
- 时间转字符串
- +(NSString *)dateToStringWithDate:(NSDate *)date dateFormat:(NSString *)dateFormat;
- 字符串转时间
- +(NSDate *)stringToDateWithString:(NSString *)string dateFormat:(NSString *)dateFormat;
- 间戳转字符串
- +(NSString *)timeIntervalToStringWithTimeInterval:(NSTimeInterval)timeInterval dateFormat:(NSString *)dateFormat;
- 字符串转时间戳
- +(NSTimeInterval)stringToTimeIntervalWithString:(NSString *)string dateFormat:(NSString *)dateFormat;
- 时间戳转特殊字符串(如果是今明两天,会将月日转换成“今天”或“明天”)
- +(NSString *)specialTimeIntervalToStringWithTimeInterval:(NSTimeInterval)timeInterval dateFormat:(NSString *)dateFormat;
- 获取当前时间戳
- +(NSTimeInterval)getNowTimeInterval;
8、UIButton+MZTouch
- 通过eventTimeInterval来设置UIButton点击间隔
9、NSArray+MZTool
- 获取数组中的最大值数组
- -(void)caculateMaxArray:(void(^)(NSArray *maxArray,NSInteger startIndex,NSInteger endIndex))callback;
10、UIColor+MZTool
- 获取图片上某个点的颜色
- +(UIColor *)colorAtPixel:(CGPoint)point withImage:(UIImage *)image;
- 根据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
- 统一处理找不到对应方法崩溃的问题
- 统一处理键值对编码找不到对应属性崩溃的问题
13、NSArray+MZLog
- 统一处理数组打印的问题
14、NSDictionary+MZLog
- 统一处理字典打印的问题
15、NSArray+MZTool
- 获取数组中的最大值数组
-
- (void)caculateMaxArray:(void(^)(NSArray *maxArray,NSInteger startIndex,NSInteger endIndex))callback;