UILabel

富文本 指定文字处理

2022-02-10  本文已影响0人  失忆的程序员
    //
    NSString *strrrrrrrrs = [NSString stringWithFormat:@"勤奋的打工人,老板嘉奖10000元"];
    // 改变颜色
    NSMutableAttributedString *lightstr = [[NSMutableAttributedString alloc] initWithString:strrrrrrrrs];
    [lightstr addAttribute:NSForegroundColorAttributeName value:[UIColor whiteColor] range:NSMakeRange(lightstr.length - 1, 1)];
    // 改变字体大小
    [lightstr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:10] range:NSMakeRange(lightstr.length - 1, 1)];
    self.label.attributedText = lightstr;

勤奋的打工人,老板嘉奖10000元 (突出元)

NSString *strUrl = [urlString stringByReplacingOccurrencesOfString:@" " withString:@""];  去掉空格

NSString *strUrl = [urlString stringByReplacingOccurrencesOfString:@" " withString:@"/"];替换字符
上一篇 下一篇

猜你喜欢

热点阅读