扫码关注官方订阅号
用uiview重写uilabel时候,重写了字距,但行距不知道怎么重写,求大神指教
认证高级PHP讲师
UILable的attributedText完成能满足你的需求
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy]; paragraphStyle.lineBreakMode = label.lineBreakMode; paragraphStyle.lineSpacing = 4.0; paragraphStyle.paragraphSpacing = 18; NSDictionary *dic = @{NSParagraphStyleAttributeName: paragraphStyle, NSForegroundColorAttributeName: RGBColor(85, 85, 85)}; NSAttributedString *att = [[NSAttributedString alloc] initWithString:text attributes:dic]; lable.attributedText = att;
你是怎么实现重写uilabel的?如果是用的 NSString 的 drawRect ,那么定 Rect 的时候注意间距即可咧。
可以参考FXLabelhttps://github.com/nicklockwood/FXLabel
https://github.com/TTTAttributedLabel/TTTAttributedLabel
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
UILable的attributedText完成能满足你的需求
你是怎么实现重写uilabel的?如果是用的 NSString 的 drawRect ,那么定 Rect 的时候注意间距即可咧。
可以参考FXLabel
https://github.com/nicklockwood/FXLabel
https://github.com/TTTAttributedLabel/TTTAttributedLabel