(ca88亚洲城手机版下载安装) iOS用UIview重写uilabel

用uiview重写uilabel时候,重写了字距,但行距不知道怎么重写,求大神指教

UILable的attributedText完成能满足你的需求

NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.lineBreakMode = label.lineBreakMode;
paragraphStyle.lineSpacing = 4.0;
paragraphStyle.paragraphSpacing = 18; NSDictionary *dic = @{NSParagraphStyleAttributeName: paragraphStyle, NSForegroundColorAttributeName: RGBColor85, 85, 85};
NSAttributedString *att = [[NSAttributedString alloc] initWithString:text attributes:dic];
lable.attributedText = att;

你是怎么实现重写uilabel的?如果是用的 NSString 的 drawRect ,那么定 Rect 的时候注意间距即可咧。

可以参考FXLabel
https://github.com/nicklockwood/FXLabel

https://github.com/TTTAttributedLabel/TTTAttributedLabel

发表评论

电子邮件地址不会被公开。 必填项已用*标注