swift -- 过去字符串宽高
2017-04-14 本文已影响10人
71150ce14a00
func getTexSize(textStr:String,font:UIFont,height:CGFloat) -> CGSize {
let normalText: String = textStr
let size = CGSize(width: 1000, height: height)
let dic = NSDictionary(object: font, forKey: NSFontAttributeName as NSCopying)
let stringSize = normalText.boundingRect(with: size, options: .usesLineFragmentOrigin, attributes: dic as? [String : AnyObject], context:nil).size
return stringSize
}