+(NSMutableAttributedString *)moneyFontGet:(NSString *)inputStr{
NSMutableAttributedString *resultStr = [[NSMutableAttributedString alloc] initWithString:inputStr];
if (inputStr.length == 0) {
}else{
NSString *frontStr;
NSString *endStr;
if ([inputStr containsString:@"."]) {
NSRange range = [inputStr rangeOfString:@"."];
frontStr = [inputStr substringFromIndex:range.location];
endStr = [inputStr substringToIndex:range.location];
NSMutableDictionary *frontDic = [NSMutableDictionary dictionary];
frontDic[NSFontAttributeName] = [UIFont boldSystemFontOfSize:16];
frontDic[NSForegroundColorAttributeName] =[ UIColor lightGrayColor];
[resultStr addAttributes:frontDic range:[inputStr rangeOfString:frontStr]];
NSMutableDictionary *endDic = [NSMutableDictionary dictionary];
endDic[NSFontAttributeName] = [UIFont boldSystemFontOfSize:20];
endDic[NSForegroundColorAttributeName] =[ UIColor blackColor];
[resultStr addAttributes:endDic range:[inputStr rangeOfString:endStr]];
NSString *money = @"¥";
NSMutableAttributedString *moneyStr = [[NSMutableAttributedString alloc] initWithString:money];
NSMutableDictionary *moneyDic = [NSMutableDictionary dictionary];
moneyDic[NSFontAttributeName] = [UIFont boldSystemFontOfSize:16];
moneyDic[NSForegroundColorAttributeName] =[ UIColor lightGrayColor];
[moneyStr addAttributes:moneyDic range:[money rangeOfString:money]];
[resultStr insertAttributedString:moneyStr atIndex:0];
}else{
}
}
return resultStr;
}
网友评论