美文网首页
如何在iOS开发中简单控制文本的行间距与行高

如何在iOS开发中简单控制文本的行间距与行高

作者: JohnXych | 来源:发表于2019-01-04 14:39 被阅读4次

NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new];paragraphStyle.lineSpacing = 10 - (label.font.lineHeight - label.font.pointSize);NSMutableDictionary *attributes = [NSMutableDictionary dictionary];[attributes setObject:paragraphStyle forKey:NSParagraphStyleAttributeName];label.attributedText = [[NSAttributedString alloc] initWithString:label.text attributes:attributes];

计算label的行高小技巧

 CGSize attSizeL = [self.taskListModel.cmUnitName boundingRectWithSize:CGSizeMake(CGRectGetWidth(self.view.frame) - 28,MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:15]}context:nil].size;

      float  LlineN = attSizeL.height / 18.0;

详情请看这里引用此博文

相关文章

网友评论

      本文标题:如何在iOS开发中简单控制文本的行间距与行高

      本文链接:https://www.haomeiwen.com/subject/cpohrqtx.html