// 计算字符串的宽度,高度
letstring:String ="swift中计算字符串的宽度和高度。swift中计算字符串的宽度和高度。swift中计算字符串的宽度和高度。"
letfont:UIFont! = UIFont(name:"EuphemiaUCAS",size:12.0)
let attributes = [NSFontAttributeName:font]
let option = NSStringDrawingOptions.UsesLineFragmentOrigin
letrect:CGRect = string.boundingRectWithSize(CGSizeMake(320.0,999.9),options: option,attributes: attributes,context:nil)
print("rect:\(rect)")
网友评论