博客> 将字符串转换成金钱显示xing
将字符串转换成金钱显示xing
2018-04-19 22:16 评论:0 阅读:128 suifumin
textFiled 键盘监测
  • (void)viewDidLoad { [super viewDidLoad]; NSString *result = [self changValueToMoney:@"100000000"]; NSLog(@"%@",result); }

-(NSString )changValueToMoney:(NSString )str{ float value = [str floatValue]; NSNumberFormatter formatter = [[NSNumberFormatter alloc]init]; formatter.numberStyle =kCFNumberFormatterCurrencyStyle; NSString newAmount = [formatter stringFromNumber:[NSNumber numberWithFloat:value]]; NSString *result = [newAmount substringFromIndex:1]; return result; } 输出结果为100,000,000.00

收藏
0
sina weixin mail 回到顶部