ZYCTool.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. //
  2. // ZYCTool.h
  3. // ttt
  4. //
  5. // Created by 张毅成 on 2018/5/14.
  6. // Copyright © 2018年 张毅成. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <UIKit/UIKit.h>
  10. //屏幕宽度比
  11. #define WIDTH_SCALE [UIScreen mainScreen].bounds.size.width / 375
  12. //屏幕高度比
  13. #define HEIGHT_SCALE [UIScreen mainScreen].bounds.size.height / 667
  14. #define kIsHaveBang [ZYCTool isHaveBang]//判断是否是刘海屏系列
  15. //高适配
  16. #define Height_SCALE(a) a*HEIGHT_SCALE
  17. //宽适配
  18. #define Width_SCALE(a) a*WIDTH_SCALE
  19. @interface ZYCTool : NSObject
  20. typedef void (^NotAvailable)(void);
  21. typedef void (^Available)(void);
  22. typedef void (^returnCancel)(void);
  23. typedef void (^returnNotarize)(void);
  24. typedef void (^returnNotarizeWithIdx)(NSInteger idx);
  25. @property (strong, nonatomic) UIAlertController *alertController;
  26. @property (copy, nonatomic) returnNotarize returnNotarize;
  27. @property (copy, nonatomic) returnCancel returnCancel;
  28. @property (copy, nonatomic) returnNotarizeWithIdx returnNotarizeWithIdx;
  29. /**
  30. 弹出alert 配两个button
  31. @param title alert的标题
  32. @param message alert的详细信息
  33. @param viewController 要弹出alert的控制器
  34. @param notarizeButtonTitle 确认按钮的title传nil的话显示@"确认"
  35. @param cancelButtonTitle 取消按钮的title传nil的话显示@"取消"
  36. @param notarize 点击确认的回调
  37. @param cancel 点击取消的回调
  38. */
  39. + (void)alertControllerTwoButtonWithTitle:(NSString *)title message:(NSString *)message target:(UIViewController *)viewController notarizeButtonTitle:(NSString *)notarizeButtonTitle cancelButtonTitle:(NSString *)cancelButtonTitle notarizeAction:(returnNotarize)notarize cancelAction:(returnCancel)cancel;
  40. /**
  41. 弹出alert 配一个button
  42. @param title alert的标题
  43. @param message alert的详细信息
  44. @param viewController 要弹出alert的控制器
  45. @param defaultButtonTitle 默认按钮的title传nil的话显示@"确认"
  46. @param defaultAction 点击默认按钮的回调
  47. */
  48. + (void)alertControllerOneButtonWithTitle:(NSString *)title message:(NSString *)message target:(UIViewController *)viewController defaultButtonTitle:(NSString *)defaultButtonTitle defaultAction:(returnNotarize)defaultAction;
  49. /**
  50. 判断相机是否可用 若不可用会弹出一个alertController 点击确认跳转到设置 取消进行NotAvailable block的操作
  51. @param viewController 要在哪个页面调用相机
  52. @param Available 相机可用时的block
  53. @param NotAvailable 相机不可用时的block
  54. */
  55. + (void)controller:(UIViewController *)viewController CameraIsAvailable:(Available)Available OrNotAvailable:(NotAvailable)NotAvailable;
  56. /**
  57. 判断相册是否可用 若不可用会弹出一个alertController 点击确认跳转到设置 取消进行NotAvailable block的操作
  58. @param viewController 要在哪个页面调用相册
  59. @param Available 相册可用时的block
  60. @param NotAvailable 相册不可用时的block
  61. */
  62. + (void)controller:(UIViewController *)viewController AlbumIsAvailable:(Available)Available OrNotAvailable:(NotAvailable)NotAvailable;
  63. /**
  64. 倒计时
  65. @param countTime 倒计时的时间(秒)
  66. @param counting 倒计时中的block
  67. @param finished 完成的block
  68. */
  69. + (void)countDownWithTime:(NSInteger)countTime AndCounting:(void(^)(NSInteger count))counting AndFinished:(void(^)(void))finished;
  70. + (void)actionSheetWithTitleArray:(NSMutableArray *)titleArray target:(UIViewController *)viewController notarizeAction:(returnNotarizeWithIdx)returnNotarizeWithIdx;
  71. /**
  72. @return 是否是刘海屏系列
  73. */
  74. + (BOOL)isHaveBang;
  75. /**
  76. @ 设置行间距和字号
  77. */
  78. +(void)setLabelSpace:(UILabel*)label withSpace:(CGFloat)space withFont:(UIFont*)font;
  79. /// 设置首行缩进和行距
  80. +(void)setLabelFirstLineHeadIndent:(UILabel*)label withSpace:(CGFloat)space withFont:(UIFont*)font setTing:(NSUInteger)headIndent;
  81. /// 设置 行间距 首行缩进 字距
  82. +(void)setLabel:(UILabel*)label withSpace:(CGFloat)space withFont:(UIFont*)font setLineSpace:(NSUInteger)headIndent setTextSpace:(CGFloat)textspace;
  83. /// 处理返回信息中的错误
  84. + (NSString *)handerResultData:(NSError *)error;
  85. + (BOOL)isNullToDictionary:(NSDictionary *)dict;
  86. /// 2019-11-20 10:46:48 ---> 11-20 10:46
  87. + (NSString *)monthAndDayAndHoursAndMinutes:(NSString *)dateString;
  88. /// 2019-11-20 10:46:48 ---> 2019-11-20 10:46
  89. /// @param dateString 2019-11-20
  90. + (NSString *)yearMonthAndDay:(NSString *)dateString;
  91. /// 2019-11-20 10:46:48 ---> 2019/11/20 10:46
  92. + (NSString *)yearMonthAndDayHourMinuesSecond:(NSString *)dateString;
  93. /// 99999 --> 9.9万 9999 --> 9.9千 999--->9.9百 99-->99
  94. + (NSString *)getCommenttext:(NSInteger)number;
  95. /// NSMutableSet ---> NSMutableArray
  96. + (NSMutableArray *)setToArray:(NSMutableSet *)set;
  97. /// 2019年12月12日
  98. + (NSString *)getYearAndMonthAndDay;
  99. /// 2019-11-20 10:46:48 ---> 11月20日
  100. + (NSString *)MonthAndDay:(NSString *)dateString;
  101. + (NSDate *)StringReturnDate:(NSString *)dateString;
  102. + (NSMutableAttributedString *)checkOfString:(NSString *)infoStr KeyString:(NSString *)keyString;
  103. + (NSMutableAttributedString *)checkOfString:(NSString *)infoStr withSearchText:(NSString *)text;
  104. + (NSMutableAttributedString *)checkOfString:(NSString *)infoStr withSearchText:(NSString *)text withColor:(UIColor *)color;
  105. + (NSMutableAttributedString *)checkOfString:(NSString *)infoStr withSearchText:(NSString *)text bgtextColor:(UIColor *)bgColor foreTextColor:(UIColor *)foreColor font:(UIFont *)font;
  106. + (NSString *)getFileNameImage:(NSString *)fileName;
  107. + (CollectDataType)returnDataType:(CollectModelType)type;
  108. @end