• NSMutableString 的使用例子


    NSString * priceString = [dict objectForKey:@"exhibition"];

        float price = [priceString floatValue];

        

        // 搜索文字

        NSString * str = [NSString stringWithFormat:@"¥%.2f万",price];

        NSString *tempStr = @"\d{1,}";

        

        NSMutableArray *results = [NSMutableArray array];

        NSRange searchRange = NSMakeRange(0, [str length]);

        NSRange range;

        NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:str];

        while ((range = [str rangeOfString:tempStr options:NSRegularExpressionSearch range:searchRange]).location != NSNotFound)

        {

            [results addObject:[NSValue valueWithRange:range]];

            searchRange = NSMakeRange(NSMaxRange(range), [str length] - NSMaxRange(range));

            [string addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20] range:range];

        }

        cell.priceLable.attributedText = string;

  • 相关阅读:
    DDD 领域驱动设计
    IOC 控制反转
    WCF
    Lucene 全文检索引擎
    Redis
    Cache 缓存
    return
    PHP中empty();和isset();的区别.
    sql 简单用语
    关系型数据库
  • 原文地址:https://www.cnblogs.com/angongIT/p/4514643.html
Copyright © 2020-2023  润新知