// // NSString+QX.h // QXLive // // Created by 启星 on 2025/5/7. // #import NS_ASSUME_NONNULL_BEGIN @interface NSString (QX) /** * 检查是否是有效字符串 **/ - (BOOL)isExist; /** 有效数字控制 @param number 原始数据 @return 返回字符串 */ + (NSString *)effectiveNum:(double)number; /// 当前字符串是否是数字 - (BOOL)isNumber; /** 获得富文本字符串 @param attriFont 字体大小 @param attriColor 字体颜色 @param attriRange 富文本区域 @return 富文本字符串 */ - (NSMutableAttributedString *)getNSMutableAttributedStringWithAttriFont:(UIFont *)attriFont attriColor:(UIColor *)attriColor isline:(BOOL)isline attriBackgroundColor:(nullable UIColor *)attriBackgroundColor lineSpacing:(CGFloat)lineSpacing attriRange:(NSRange)attriRange; /** 删除线 @param textColor 文本颜色 @param lineColor 删除线颜色 @param range 删除范围 @return 富文本字符串 */ - (NSAttributedString *)deleteLineWithTextColor: (nullable UIColor *)textColor lineColor: (nullable UIColor *)lineColor range: (NSRange)range; - (NSAttributedString *)deleteLineWithTextColor: (nullable UIColor *)textColor lineColor: (nullable UIColor *)lineColor; - (NSAttributedString *)deleteLineWithTextColor: (nullable UIColor *)textColor; - (NSAttributedString *)deleteLine; /** 验证有效手机号 @param phoneNum 手机号 @return 是否有效 */ + (BOOL)effectivePhoneNum:(NSString *)phoneNum; + (BOOL)effectivePhoneNum:(NSString *)phoneNum validLength:(NSInteger)length; /** 生成uuid 追加字符串 */ //+ (instancetype)effectivePhoneNumeffectivePhoneNum; /** * 获取时间 [@"y"]; // 2017 [@"yy"]; // 17 [@"yyy"]; // 2017 [@"yyyy"]; // 2017 [@"M"]; // 8 [@"MM"]; // 08 [@"MMM"]; // 8月 [@"MMMM"]; // 八月 [@"d"]; // 3 [@"dd"]; // 03 [@"D"]; // 215,一年中的第几天 [@"h"]; // 4 [@"hh"]; // 04 [@"H"]; // 16 24小时制 [@"HH"]; // 16 [@"m"]; // 28 [@"mm"]; // 28 [@"s"]; // 57 [@"ss"]; // 04 [@"E"]; // 周四 [@"EEEE"]; // 星期四 [@"EEEEE"]; // 四 [@"e"]; // 5 (显示的是一周的第几天(weekday),1为周日。) [@"ee"]; // 05 [@"eee"]; // 周四 [@"eeee"]; // 星期四 [@"eeeee"]; // 四 [@"z"]; // GMT+8 [@"zzzz"]; // 中国标准时间 [@"ah"]; // 下午5 [@"aH"]; // 下午17 [@"am"]; // 下午53 [@"as"]; // 下午52 */ //+ (NSString *)transformTimeInterval:(NSTimeInterval)sec byFormatter:(NSString *)formatter; // ///// 今天显示(时:分)(9:00) 昨日显示(昨天 时:分)(昨天 10:00) 其余显示(年/月/日)(2019/11/06) ///// @param sec 时间戳 //+ (NSString *)transformTodayYesterdayAndOtherTimeInterval:(NSTimeInterval)sec; /** 转换为升序key排列的URL参数格式的key=Value形式的字符串 @param dict 参数列表 @return 格式化后的字符串 */ + (NSString *)transformByAscendingWithDict:(NSDictionary *)dict; /** 判断data的类型 @return content-Type */ + (NSString *)contentTypeWithImageData:(NSData *)data; /// 手机号脱敏 - (NSString *)showMoblePhoneNumber; - (NSDictionary *)parseParameters; /// 格式化字符串的长短 /// @param limit 限制显示几个字符 /// @param suffix 超出部分的显示字符 - (NSString *)formatterToLimitNumStrWith:(NSUInteger)limit suffixStr:(nullable NSString *)suffix; - (NSString *)formatterToLimitNumStrWith:(NSUInteger)limit; /** 显示热度值 @param count 热度值 @return 返回字符串 */ + (NSString *)qx_showHotCountNum:(int64_t)count; /// 保留两位 + (NSString *)qx_showHotCountNumDouble:(int64_t)count ; /** * 显示房间名字 */ - (NSString *)qx_showRoomName; /** 订单倒计时 type == 1 返回 00:00:00 type == 2 返回 00时00分00秒 */ + (NSString *)timeStrFromInterval:(long)lastTime type:(NSInteger)type; + (BOOL)inputShouldLetterOrNum:(NSString *)inputString; + (NSString *)safeString:(NSString *)string ByAppendingString:(NSString *)aString; /** 超过9999数量用w显示并保留1位小数(如14500 = 1.5w) */ - (NSString *)tenThousandFormatString; - (NSInteger)ageWithDateOfBirth; /// 传入秒 得到 几天 几小时 + (NSString*)getTimeWithSecond:(long long)second; @end NS_ASSUME_NONNULL_END