废话不多说了,直接给大家贴代码了,具体代码如下所示:
?| 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 垂直居中(ios中uilabel text两边对齐的实现代码","p":true,"g":[{"type":"sug","sa":"s_1","q":"ios uilabel 垂直居中"}],"slid":"111929825354895","queryi](/zb_users/upload/2022/10/1640143143-0.jpg)
以上所述是小编给大家介绍的ios中uilabel text两边对齐的实现代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对服务器之家网站的支持!
原文链接:http://blog.csdn.net/sevenquan/article/details/54343654








发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。