最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
iOS中UILabel text两边对齐的实现代码
时间:2022-06-25 23:32:00 编辑:袖梨 来源:一聚教程网
废话不多说了,直接给大家贴代码了,具体代码如下所示:
| 代码如下 | 复制代码 |
-(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]; returnattrString; } NSString*constmsg = @"6日,“幼儿园老师让带一条鱼”的微博突然间就火了!占领朋友圈!征服全国网友.图片甚至遭网友恶搞:水煮鱼、生鱼片都出来了。1月7日,记者在茫茫人海之中,历经千辛万苦终于在浙江慈溪找到了这位被网友吐槽的“粗心”家长!来听听他的解释吧"; self.lbView.attributedText = [self setTextString:msg]; | |
相关文章
- 将魂师怎么获得b级神君 b级神君获取及培育方法攻略 12-16
- poki小游戏入口在哪里精准直达-poki小游戏入口在哪里一键速查入口 12-16
- 逆战未来磐石机甲如何使用 12-16
- 漫蛙网页版免费入口分享 manwa漫画免费阅读页面 12-16
- 巨神军师甄姬怎么组队 12-16
- 蛙漫画官方页面免费漫画观看与下载入口-蛙漫画官方正版免费资源 12-16
