我是靠谱客的博主 舒心期待,这篇文章主要介绍iOS中UILabel text两边对齐的实现代码,现在分享给大家,希望可以做个参考。

废话不多说了,直接给大家贴代码了,具体代码如下所示:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
-(NSAttributedString *)setTextString:(NSString *)text { NSMutableAttributedString *mAbStr = [[NSMutableAttributedString alloc] initWithString:text]; NSMutableParagraphStyle *npgStyle = [[NSMutableParagraphStyle alloc] init]; npgStyle.alignment = NSTextAlignmentJustified; npgStyle.paragraphSpacing = 11.0; npgStyle.paragraphSpacingBefore = 10.0; npgStyle.firstLineHeadIndent = 0.0; npgStyle.headIndent = 0.0; NSDictionary *dic = @{ NSForegroundColorAttributeName:[UIColor blackColor], NSFontAttributeName :[UIFont systemFontOfSize:15.0], NSParagraphStyleAttributeName :npgStyle, NSUnderlineStyleAttributeName :[NSNumber numberWithInteger:NSUnderlineStyleNone] }; [mAbStr setAttributes:dic range:NSMakeRange(0, mAbStr.length)]; NSAttributedString *attrString = [mAbStr copy]; return attrString; } NSString* const msg = @"6日,“幼儿园老师让带一条鱼”的微博突然间就火了!占领朋友圈!征服全国网友.图片甚至遭网友恶搞:水煮鱼、生鱼片都出来了。1月7日,记者在茫茫人海之中,历经千辛万苦终于在浙江慈溪找到了这位被网友吐槽的“粗心”家长!来听听他的解释吧"; self.lbView.attributedText = [self setTextString:msg];

以上所述是小编给大家介绍的iOS中UILabel text两边对齐的实现代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对靠谱客网站的支持!

最后

以上就是舒心期待最近收集整理的关于iOS中UILabel text两边对齐的实现代码的全部内容,更多相关iOS中UILabel内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(103)

评论列表共有 0 条评论

立即
投稿
返回
顶部