//
//  NSString+Category.h
//  SharedParking
//
//  Created by gui_huan on 2018/4/16.
//  Copyright © 2018年 gui_huan. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface NSString (Category)

///文字尺寸
- (CGSize)stringSizeWithFont:(UIFont *)font Size:(CGSize)size;

/// 移除首尾空格和换行
- (NSString *)qhw_stringByTrimingWhitespace;

/// 根据字符串获取手机运营商.
- (NSString *)qhw_carrier;

/// 是否是有效的手机号码
- (BOOL)qhw_validPhoneNumber;

/// 是否是有效的密码
- (BOOL)qhw_validPassword;

/// 是否全部是数字
- (BOOL)qhw_validDigits;

/// 是否是金额. 整数位最多十位，小数为最多为两位，可以无小数位.
- (BOOL)qhw_validAmount;

/// 日历中的数字 得到星期
+ (NSString *)weekdayOfCalendarIndex:(NSInteger)index;

/// 字符串是否纯数字
- (BOOL)isPuloIntNumberString;

/// 判断是否有效身份证
+ (BOOL)Chk18PaperId:(NSString *)cardNumber;

/// 从指定格式,时间戳获取时间
+ (NSString *)defaultTimeFromFormatter:(NSString *)fomatter timeString:(NSString *)string;
/// 从指定格式,时间戳获取时间
+ (NSString *)timeFromFormatter:(NSString *)fomatter timeString:(NSString *)string;
///获取当前年月
+(NSString*)getCurrentYearMonthWithFormatter:(NSString *)dateFormat;
+(NSString*)getCurrentYearMonth;
/// 昨日日期
+ (NSString *)lastDayWithFormatter:(NSString *)formatter;


/// 与当前时间差值
/// - Parameters:
///   - dateFormat: 格式
///   - timeDiff: 时间差
+(NSString*)getCurrentDayWithFormatter:(NSString *)dateFormat timeDiff:(CGFloat)timeDiff;


//金钱转换成千分号格式
- (NSString *)changeMoneyFormat:(NSNumberFormatterStyle)style;

/// 是否有emoji表情
+ (BOOL)stringContainsEmoji:(NSString *)string;

/// 过滤<null>, (null)字符
- (NSString *)filterNullStringWithString:(NSString *)replaceString;

/// 限定中英文
- (BOOL)isChineseOrEnglish;

/// 限数字和字母
- (BOOL)isNumberOrEnglish;

/// 中文 英文 空格 -
- (BOOL)isChineseOrEnglishWhiteAndDash;

/// 给借记卡，信用卡四位加一空格
- (NSString *)insertSpacePreFourCharacter;

/// 身份证加空格
- (NSString *)ID18DigitCardInsertSpace;

/// 银行卡中间数字替换成*
- (NSString *)bankCardNoExchangeWithStar;

/// 去除字符串中间的空格
- (NSString *)stringRemoveSpace;

/// 限制textfield的输入长度
+ (BOOL)canChangeTextField:(UITextField *)textfield withString:(NSString *)string length:(NSInteger)length;

/// 是否合格的登陆密码
- (BOOL)isValidLoginPassword;

/// textfield输入银行卡自动空格 并限制长度
+ (NSString *)textFieldBankInsertSpaceOriginal:(NSString *)original range:(NSRange)range string:(NSString *)string length:(NSInteger)length;

+ (NSString *)textFieldIDCardInsertSpaceOriginal:(NSString *)original range:(NSRange)range string:(NSString *)string length:(NSInteger)length;

/// 手机号加 *
+ (NSString *)concealPhoneNumber:(NSString *)number;

/// 加密字符串
//+ (NSString *)cryptographicStringFromString:(NSString *)sourceString;

- (NSDictionary *)JSONFromString;

///计算文字宽高
+(CGSize) boundingALLRectWithSize:(NSString*) txt Font:(UIFont*) font Size:(CGSize) size;



/**
 字符串中某个字符的自定义颜色

 @param totalString 完整字符串
 @param totalColor 完整字符串颜色
 @param specialString 所需更改的字符
 @param SpecialColor 所需更改的字符颜色
 @param fontSize 所需更改的字符大小
 @return <#return value description#>
 */
+ (NSAttributedString *)getShowAttributedStringWithTotalString:(NSString *)totalString totalColor:(UIColor *)totalColor specialString:(NSString *)specialString specialColor:(UIColor *)SpecialColor specialfontOfSize:(CGFloat)fontSize;

///同下
+ (NSAttributedString *)getShowAttributedStringWithNormalString:(NSString *)normalString normalColor:(UIColor *)normalColor specialString:(NSString *)specialString specialColor:(UIColor *)SpecialColor specialfontOfSize:(CGFloat)fontSize;
/**
 ///两种不同形式的String组合
 
 @param normalString 普通状态String
 @param specialString 另一种显示
 @param color <#color description#>
 @param fontSize <#fontSize description#>
 @return <#return value description#>
 */
+ (NSAttributedString *)getShowAttributedStringWithNormalString:(NSString *)normalString specialString:(NSString *)specialString specialColor:(UIColor *)color specialfontOfSize:(CGFloat)fontSize;


///
+ (NSAttributedString *)getShowAttributedStringWithNormalString:(NSString *)normalString normalColor:(UIColor *)normalColor specialString:(NSString *)specialString specialColor:(UIColor *)SpecialColor specialFont:(UIFont *)font;

/*!
 @method
 @describe 计算获取文本的大小
 */
+ (CGSize)calculationTextNeedSizeWithText:(NSString *)text
                                     font:(CGFloat)font
                                    width:(CGFloat)width;



/**
 文本间距

 @param str 文本
 @param space 间距
 @return <#return value description#>
 */
+ (NSMutableAttributedString *)getOrderDetailString:(NSAttributedString *)str lineSpace:(CGFloat)space;
/**
 <#Description#>

 @param size 依附视图的大小
 @param text 文本
 @param font 文本大小
 @return 文本居于视图中心时的起始位置
 */
+ (CGPoint)calculationPointWithSize:(CGSize)size
                                text:(NSString *)text
                                font:(CGFloat)font;

/**
 调用一个get方法，也不算添加属性，仅方便书写
 金钱单位转换
 */
@property (nonatomic, copy)NSString *moneyConversion;

//stringToDictionary
+ (NSDictionary *)stringToDictionary:(NSString *)str;

/**
 //把没有双引号和用了单引号的json字符串转化为标准格式字符串;


 @param json <#json description#>
 @return <#return value description#>
 */
+ (NSString *)changeJsonStringToTrueJsonString:(NSString *)json;



/**
 <#Description#>

 @param aString 获取汉字转成拼音字符串 通讯录模糊搜索 支持拼音检索 首字母 全拼 汉字 搜索
 @return <#return value description#>
 */
+ (NSString *)transformToPinyin:(NSString *)aString;


/**
 获取Cookie缓存

 @return <#return value description#>
 */
+ (NSMutableString*)getCookieValue;


+ (NSString *)replaceHasPrefix:(NSString *)fixStr str:(NSString *)str;

+ (NSString *)getRandStringWithLength:(int)length;

@end

