UILabel设定行间距方法
生活随笔
收集整理的這篇文章主要介紹了
UILabel设定行间距方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
NSString *textStr = @"iPhone規定:任何應用想訪問麥克風,必須被授權麥克風服務。請進入“設置”->“隱私”->“麥克風”中打開QQ空間的麥克風服務。";UIFont *textFont = [UIFont systemFontOfSize:14];CGSize textSize = [textStr sizeWithFont:textFontconstrainedToSize:CGSizeMake(bounds.size.width - 40, QZONE_SCREEN_HEIGHT)];;UILabel *openMicPrivilegeTipsLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, textSize.width, textSize.height)];openMicPrivilegeTipsLabel.textColor = DefaultDescriptionText2ColorInDefaultTheme;openMicPrivilegeTipsLabel.text = textStr;openMicPrivilegeTipsLabel.backgroundColor = [UIColor clearColor];openMicPrivilegeTipsLabel.textAlignment = UITextAlignmentLeft;openMicPrivilegeTipsLabel.font = [UIFont systemFontOfSize:14];openMicPrivilegeTipsLabel.numberOfLines = 0;// 調整行間距NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:textStr];NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];[paragraphStyle setLineSpacing:6];[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [textStr length])];openMicPrivilegeTipsLabel.attributedText = attributedString;[_tipsBG addSubview:openMicPrivilegeTipsLabel];[openMicPrivilegeTipsLabel sizeToFit];
轉載于:https://www.cnblogs.com/sesexxoo/p/6189909.html
總結
以上是生活随笔為你收集整理的UILabel设定行间距方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 运费险黑名单多久消除 三个月后
- 下一篇: 有什么能制作GIF动态图的软件 动图软件