| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- //
- // MOTools.h
- // MiMoLive
- //
- // Created by SuperC on 2023/10/9.
- //
- #import <Foundation/Foundation.h>
- NS_ASSUME_NONNULL_BEGIN
- @interface MOTools : NSObject
- @property (nonatomic, assign) NSInteger seed;
- //16进制颜色转换
- + (UIColor *)colorWithHexString:(NSString *)hexString;
- + (UIColor *)colorWithHexString:(NSString *)hexString alpha:(CGFloat)alpha;
- ///计算文字高度
- + (CGFloat)calculateRowHeight:(NSString *)string fontSize:(NSInteger)fontSize andWidth:(CGFloat)width;
- ///计算文字高度
- + (CGFloat)calculateRowHeight:(NSString *)string font:(UIFont *)font andWidth:(CGFloat)width;
- /// 计算文字高度 无行间距
- + (CGFloat)calculateRowHeightNoLine:(NSString *)string font:(UIFont *)font andWidth:(CGFloat)width;
- /// 计算文字高度 无行间距版 (注意跟上个方法做区分)
- + (CGFloat)calculateRowHeightNoLineSpacing:(NSString *)string fontSize:(NSInteger)fontSize andWidth:(CGFloat)width;
- /// 计算文字长度
- /// @param string 文字
- /// @param font 字号
- + (CGFloat)getWidthWithString:(NSString *)string font:(UIFont *)font;
- //获取文字的尺寸
- + (CGSize)getSizeFrom:(NSString *)content font:(UIFont *)font maxSize:(CGSize)maxSize;
- /// 根据颜色生成一张图片
- /// @param color 颜色
- + (UIImage*)createImageWithColor:(UIColor*)color;
- /**
- * 绘制渐变色的矩形UIImage
- *
- * @param bounds UIImage的bounds
- * @param colors 渐变色数组,可以设置两种颜色
- * @param gradientType 渐变的方式:0:水平渐变 1:竖直渐变 2:向下对角线渐变 3:向上对角线渐变
- *
- * @return 渐变色的UIImage
- */
- + (UIImage*)createGradientRectImageWithBounds:(CGRect)bounds
- Colors:(NSArray*)colors
- GradientType:(int)gradientType;
- /// 将数组中的字符串按照拼音排序(先比较第一个汉字,然后比较第二个汉字,并且第一个汉字按照音标排序,非汉字排在后面,胥<徐<许<x<xu,许1<许3<许21,3502<123456)
- /// @param oldArray 需要排序的数组,每个元素都必须是同一种类型
- /// @param keyPath 如果oldArray的数组元素不是NSString类型,则[元素 valueForKey:keyPath]必须是字符串类型
- + (NSArray *)sortArrayByPinYin:(NSArray *)oldArray objectTextKeyPath:(NSString *)keyPath;
- //获取设备信息
- + (NSDictionary *)getDeviceInfo;
- //获取设备字符串
- + (NSString *)getDeviceString;
- ///获取设备类型
- + (NSString *)getCurrentDeviceModel;
- /// 将传入的数字进行模式化 - (1345 -> 1000)
- /// - Parameter number: 参数
- + (NSInteger)keepFirstDigitAndZeroOthersWith:(double)number;
- /// 将传入的数字进行模式化 - (大于1W -> 10000 , 小于1W大于1000, 则为1000, 如果小于1000则为具体数字)
- + (NSInteger)keepFirstZeroOthersWith:(double)number;
- /// 设置这一次弹出手机绑定弹窗设备的时间
- + (void)setTimeOfShowBindDevice:(NSDate *)time;
- /// 获取上一次手机绑定弹窗的时间
- + (NSDate *)getTimeOfShowBind;
- /// 是否时间过了一天
- + (BOOL)shouldShowAlertWithLastTime:(NSDate *)lastTime;
- /// 设置签到时间 - 根据用户ID
- + (void)setTimeOfShowSignDevice:(NSDate *)time;
- /// 获取上一次签到时间 */
- + (NSDate *)getTimeOfShowSign;
- - (NSInteger)mo_nextDoubleAndMin:(NSInteger)min And:(NSInteger)max;
- + (UIViewController *)currentViewController;
- /// 更新服务器时间的差值
- + (void)toUpdataTheRedSysTimeWith:(int64_t)sysTime;
- + (UIView *)containsViewOfClass:(Class)viewClass inView:(UIView *)view;
- + (BOOL)toJudgeShowWame;
- /// 获取并本地存储图片
- + (void)fetchAndStoreImageWithUrl:(NSString *)url completeBlock:(void (^)(UIImage *image))completeBlock;
- /// 邮箱判断正则
- + (BOOL)isValidEmail:(NSString *)email;
- /// 手机号字符串**替换
- + (NSString *)maskPhoneNumber:(NSString *)phoneNumber;
- + (NSString *)getValueWithKey:(NSString *)key urlString:(NSString *)urlString;
- + (NSString *)getValueWithKey:(NSString *)key url:(NSURL *)url;
- //字典转json格式字符串:
- + (NSString *)dictionaryToJson:(NSDictionary *)dic;
- //json格式字符串转字典:
- + (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString;
- //根据VIP 类型 和 尺寸 生成对应的图片
- + (UIImage *)getVipImgIconWith:(NSInteger)type AndSize:(CGSize)size;
- //根据道具分类, 拿分类图片
- + (UIImage *)toGetThePropsTypeWith:(NSInteger)type;
- /// 退出键盘
- + (void)dismissKeyboard;
- //判断两个字符串数组 是否一样
- + (BOOL)isStringArrayContentEqualIgnoringOrder:(NSArray<NSString *> *)array1 array2:(NSArray<NSString *> *)array2;
- ///去生成一个随机ID
- + (NSString *)generateUniqueID;
- /// 超出指定长度替换成...
- /// - Parameters:
- /// - string: 字符串
- /// - maxLength: 最大长度
- + (NSString *)trimString:(NSString *)string maxLength:(NSInteger)maxLength;
- ///时间戳转几分钟前
- + (NSString *)timeAgoStringFromTimeStamp:(NSTimeInterval)timeStamp;
- @end
- NS_ASSUME_NONNULL_END
|