/**
参数1>预期尺寸,宽度固定,高度尽量大
参数2>选项,换行文本,统一使用usesLineFragmentOrigin
参数3>attributes:指定字体字典
*/
let margin : CGFloat = 12
let viewSize = CGSize(width: [UIScreen mainScreen].bounds.size.width) - 2 * margin, height: CGFloat(MAXFLOAT))
let font = UIFont.systemFont(ofSize: 15)
var height = (text as NSString).boundingRect(with: viewSize, options: [.usesLineFragmentOrigin], attributes: [NSFontAttributeName:font], context: nil).height
网友评论