富文本

 UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, 310, 350)];
    [label setLineBreakMode:NSLineBreakByWordWrapping];
    label.numberOfLines =0;
    [label setFont:[UIFont systemFontOfSize:14]];
    NSMutableAttributedString *content = [[NSMutableAttributedString alloc]initWithString:[NSString stringWithFormat:@"乔丹  科比  詹姆斯 杜兰特 库里 韦德"]];
    NSRange contentRange = {0,[content length]};
//    下划线
    [content addAttribute:NSUnderlineStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:contentRange];
//    label.strikeThroughEnabled=YES
    
//    删除线
    [content addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(3,12)];
//字体大小
    [content addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20.0] range:NSMakeRange(0, 2)];
//    字体颜色
    [content addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(3, 10)];
//删除线的颜色
    [content addAttribute:NSStrikethroughColorAttributeName value:[UIColor greenColor] range:NSMakeRange(8, 10)];
    
   
    label.attributedText = content;
    [self.view addSubview:label];
image.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容