iOS开发字符串处理篇之货币格式化

一、货币格式化

  NSNumberFormatter *currencyFormatter = [[NSNumberFormatter alloc] init];
    currencyFormatter.numberStyle = kCFNumberFormatterDecimalStyle;
    NSString *currenctStr = [currencyFormatter stringFromNumber:[NSNumber numberWithInteger:currencyNumber]];
    return [NSString stringWithFormat:@"¥%@",currenctStr];//因为我需要的样式是¥123,456,789没有后面的.00
    /*
    NSNumberFormatterNoStyle = kCFNumberFormatterNoStyle,  // 123456789
    NSNumberFormatterDecimalStyle = kCFNumberFormatterDecimalStyle,// 123,456,789
    NSNumberFormatterCurrencyStyle = kCFNumberFormatterCurrencyStyle,//¥123,456,789.00
    NSNumberFormatterPercentStyle = kCFNumberFormatterPercentStyle, //-539,222,988%
    NSNumberFormatterScientificStyle = kCFNumberFormatterScientificStyle,//1.23456789E8
    NSNumberFormatterSpellOutStyle = kCFNumberFormatterSpellOutStyle //一亿二千三百四十五万六千七百八十九
     */

  

posted @ 2018-01-29 15:38  TheYouth  阅读(525)  评论(0编辑  收藏  举报