ios(oc)富文本

- (void) demo

{

NSMutableAttributedString*abs = [[NSMutableAttributedStringalloc]initWithString:@"asl;kda;sllda';了接口设计拉克是大家"];

//[abs beginEditing];

//字体大小

[absaddAttribute:NSFontAttributeName

value:[UIFontsystemFontOfSize:20.0]

range:NSMakeRange(0,2)];

//字体颜色

[absaddAttribute:NSForegroundColorAttributeName

value:[UIColorblueColor]

range:NSMakeRange(2,2)];

//下划线

[absaddAttribute:NSUnderlineStyleAttributeName

value:@(NSUnderlineStyleSingle)

range:NSMakeRange(3,7)];

//字体的设置

[absaddAttribute:NSFontAttributeName

value:[UIFontfontWithName:@"AppleGothic"size:24]

range:NSMakeRange(2,6)];

//删除线

[absaddAttribute:NSStrikethroughStyleAttributeNamevalue:@(NSUnderlinePatternSolid|NSUnderlineStyleSingle)range:NSMakeRange(10,7)];

//删除线的颜色依附于删除线

[absaddAttribute:NSStrikethroughColorAttributeNamevalue:[UIColorredColor]range:NSMakeRange(10,7)];

self.label.attributedText= abs;

//self.label.numberOfLines = 0;

}

你可能感兴趣的:(ios(oc)富文本)