給定文字大小(字體)郊楣,和 段落 寬度憔恳,
根據(jù) 任意的 文字段落, 給出相應的 段落 寬度
class func heightWithModel(model: FoodCourseSerialModel) -> CGFloat{
let titleH: CGFloat = 20
let marginY: CGFloat = 10
let dict = [NSFontAttributeName: UIFont.systemFontOfSize(17)]
var height: CGFloat = marginY + titleH + marginY
if model.course_subject != nil {
let h = NSString(string: model.course_subject!).boundingRectWithSize(CGSizeMake(kScreenWidth - 20*2, CGFloat.max), options: .UsesLineFragmentOrigin, attributes: dict, context: nil).size.height
let newHeight = CGFloat(Int(h) + 1)
height += (newHeight + marginY)
}
return height
}
最后編輯于 :
?著作權歸作者所有,轉載或內容合作請聯(lián)系作者