/// 计算文本的高度
static func textHeight(text: String, fontSize: CGFloat, width: CGFloat) -> CGFloat {
return text.boundingRect(with:CGSize(width: width, height:CGFloat(MAXFLOAT)), options: .usesLineFragmentOrigin, attributes: [.font:UIFont.systemFont(ofSize: fontSize)], context:nil).size.height+5
}
/// 计算文本的宽度
static func textHieght(text: String, fontSize: CGFloat, height: CGFloat) -> CGFloat {
return text.boundingRect(with:CGSize(width:CGFloat(MAXFLOAT), height: height), options: .usesLineFragmentOrigin, attributes: [.font:UIFont.systemFont(ofSize: fontSize)], context:nil).size.height
}
网友评论