美文网首页iOS Development
swift -- 过去字符串宽高

swift -- 过去字符串宽高

作者: 71150ce14a00 | 来源:发表于2017-04-14 15:36 被阅读10次
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 -- 过去字符串宽高

本文链接:https://www.haomeiwen.com/subject/sunwattx.html