Brak opisu

FLStringHelper.h 4.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. //
  2. // FLStringHelper.h
  3. // FirstLink
  4. //
  5. // Created by unicode on 14-9-25.
  6. // Copyright (c) 2014年 FirstLink. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import <TTTAttributedLabel.h>
  10. @interface NSString (MyAdditions)
  11. - (NSString *)md5;
  12. @end
  13. @interface FLStringHelper : NSObject
  14. + (NSString*)convertNumberToString:(int)num;
  15. + (CGRect)rectOfString:(NSString*)text font:(UIFont*)font width:(CGFloat)width;
  16. + (CGRect)rectOfString:(NSString*)text font:(UIFont*)font height:(CGFloat)height;
  17. + (CGSize)sizeOfAttributeString:(NSString*)text font:(UIFont*)font width:(CGFloat)width maxRow:(int)maxRow;
  18. + (CGSize)sizeOfAttributeString:(NSString*)text lineSpace:(CGFloat)lineSpace width:(CGFloat)width font:(UIFont *)font maxRow:(NSInteger)maxRow;
  19. + (NSString*)replaceNilWithEmpty:(NSString*)string;
  20. + (NSString*)convertFenToYuan:(NSString*)fen;
  21. + (CGFloat)convertFenStringToYuanValue:(NSString *)fenStr;
  22. + (NSString *)convertFenToRMBmoneyString:(NSString*)fen;
  23. + (NSString*)convertStringToTipTime:(NSString*)time;
  24. + (NSString*)convertStringToTipTime:(NSString*)time formate:(NSString *)formate;
  25. + (NSString*)dateForMessage:(NSDate*)date;
  26. + (NSString*)convertDate:(NSDate*)date formate:(NSString*)formate;
  27. + (NSString*)cdnParamaterString:(int)width;
  28. + (NSString*)cdnParamaterString:(int)width height:(int)height;
  29. + (NSString*)componentOfDay:(NSString*)time;
  30. + (NSDateFormatter *)dateFormat;
  31. + (NSDate *)convertToDateFromString:(NSString *)string;
  32. + (NSDate *)convertToShortDateFromString:(NSString *)string;
  33. + (NSString *)convertDictionary2String:(NSDictionary *)dict;
  34. // 转化字符串为年月日格式
  35. + (NSString *)convertToShortDateStringFromString:(NSString *)timeString;
  36. // 将倒计时(秒)转为剩余天时分秒字符串
  37. + (NSString *)convertTimeIntervalToCountString:(NSTimeInterval)timeInterval;
  38. // 将倒计时(秒)转为剩余时分秒字符串
  39. + (NSString *)convertTimeIntervalToHourCountString:(NSTimeInterval)timeInterval;
  40. // 将倒计时(秒)转为剩余时:分:秒字符串
  41. + (NSString *)convertTimeIntervalToHourCountStringStyleColon:(NSTimeInterval)timeInterval;
  42. + (NSTimeInterval)timeIntervalFromString:(NSString *)dateString;
  43. // 转化字符串为日期显示样式(超过24H,2015-2-3, 24H内:5小时前,1h内:45分钟前)
  44. + (NSString *)convertToPredigestStringFromString:(NSString *)timeString; // 和本地时间比较
  45. + (NSString *)convertToPredigestStringFromString:(NSString *)timeString baseTime:(NSDate *)baseTime; // 和指定时间比较,如果baseTime为nil 同上
  46. + (NSString *)convertToPredigestStringFromTimeInterval:(NSTimeInterval)timeInterval shortTimeStr:(NSString *)shortTimeStr;
  47. // 转化为日期样式(09-12, 省去年份)
  48. + (NSString *)convertToTimeStrNoYear:(NSString *)timeStr;
  49. // 转化为日期样式(09-12, 5小时前, 45分钟前,刚刚)
  50. + (NSString *)convertToCommonFormateFromString:(NSString *)timeString baseTime:(NSString *)baseTime;
  51. + (NSDateComponents *)convertToComponentsFormateFromString:(NSString *)timeString baseTime:(NSString *)baseTime;
  52. + (NSDateComponents*)convertSecondToComponents:(NSTimeInterval)second baseTime:(NSString *)baseTime;
  53. + (NSDateComponents*)convertSecondToComponents:(NSTimeInterval)second;
  54. + (BOOL)isUrlString:(NSString *)string; // 是否是链接
  55. + (BOOL)isValidString:(NSString *)string; // 是否有效字符串,非空
  56. + (NSAttributedString *)attStringWithText:(NSString *)text color:(UIColor *)color font:(UIFont *)font lineSpace:(CGFloat)lineSpace;
  57. + (NSAttributedString *)attStringWithText:(NSString *)text lineSpace:(CGFloat)lineSpace;
  58. + (NSAttributedString *)attStringWithText:(NSString *)text
  59. color:(UIColor *)color
  60. font:(UIFont *)font
  61. subText:(NSString *)subText
  62. subColor:(UIColor *)subColor
  63. subFont:(UIFont *)subFont;
  64. + (id)convertStringToJson:(NSString *)string;
  65. + (NSString *)jsonStrWithDict:(NSDictionary *)dict;
  66. // 数字处理 (不大于1W,显示9999 过1w 显示1万,不超过2W,显示1万), 不处理负数
  67. + (NSString *)convertToShortNumStr:(NSInteger)count;
  68. @end