swift -- 过去字符串宽高

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
    
}

你可能感兴趣的:(swift -- 过去字符串宽高)