最新下载
热门教程
- 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]; | |
相关文章
- 《晶核》亲爱的观众 请完全信赖你的眼睛 06-30
- 晶核手游职业伤害排行 晶核手游强势职业排名 06-30
- 找字高手第一关天怎么过-第1关天找出5个常用字图文攻略 06-30
- 7月新游推荐:腾讯、网易接连带来重磅新作:士官长首次登陆PS5平台 06-30
- 《晶核》烈饮争锋攻略丨共赴金羊毛佳酿小酌一杯 06-30
- 使命召唤手游选枪攻略 搭配你的专属武器装备 06-30
