Believe in your own future, will thank yourself right now Sinner Yun

Sinner_Yun

通过文字计算lab高度

 

 

 1   var attrButes:[NSAttributedString.Key : Any]! = nil;
 2         let paraph = NSMutableParagraphStyle()
 3         paraph.lineSpacing = 8
 4         attrButes = [NSAttributedString.Key.font:UIFont.systemFont(ofSize: 13.5),NSAttributedString.Key.paragraphStyle:paraph]
 5         
 6         let size:CGRect = model.content!.boundingRect(with: CGSize(width: HL_APP_WIDTH - 30 , height: CGFloat.greatestFiniteMagnitude), options: NSStringDrawingOptions.usesLineFragmentOrigin, attributes: attrButes, context: nil)
 7         
 8 //        detailHeaderView.contTextLab.text = ""
 9         detailHeaderView.contTextLab.attributedText = NSAttributedString(string: model.content!, attributes: attrButes)
10         detailHeaderView.contTextLab.numberOfLines = 0
11         detailHeaderView.contTextLab.sizeToFit()
12         context_H = size.height 

 

posted on 2019-05-06 18:59  Sinner_Yun  阅读(596)  评论(0编辑  收藏  举报

导航