本文共 914 字,大约阅读时间需要 3 分钟。
网上找了半天大部分都有各种各样的毛病。。话不多说,先看效果
代码附上:
/***********
-(NSAttributedString *)setTextString:(NSString *)text{
NSMutableAttributedString *mAbStr = [[NSMutableAttributedStringalloc]initWithString:text];
NSMutableParagraphStyle *npgStyle = [[NSMutableParagraphStylealloc]init];
npgStyle.alignment =NSTextAlignmentJustified;
npgStyle.paragraphSpacing =11.0;
npgStyle.paragraphSpacingBefore =10.0;
npgStyle.firstLineHeadIndent =0.0;
npgStyle.headIndent =0.0;
NSDictionary *dic = @{
NSForegroundColorAttributeName:[UIColorcolorWithHexString:@"6a3906"],
NSFontAttributeName:[UIFontsystemFontOfSize:15.0],
NSParagraphStyleAttributeName :npgStyle,
NSUnderlineStyleAttributeName :[NSNumbernumberWithInteger:NSUnderlineStyleNone]
};
[mAbStrsetAttributes:dicrange:NSMakeRange(0, mAbStr.length)];
NSAttributedString *attrString = [mAbStrcopy];
return attrString;
}
*/引用直接
/*****
text.attributedText = [selfsetTextString:String];
*//