2016-04-11 10 views

cevap

0

Kullanımı: En UIView's yüksekliğine

func rectForText(text: String, font: UIFont, maxSize: CGSize) -> CGSize { 
    let attrString = NSAttributedString.init(string: text, attributes: [NSFontAttributeName:font]) 
    let rect = attrString.boundingRectWithSize(maxSize, options: NSStringDrawingOptions.UsesLineFragmentOrigin, context: nil) 
    let size = CGSizeMake(rect.size.width, rect.size.height) 
    return size 
} 

let labelSize = rectForText("your text here", font: UIFont.systemFontOfSize(your font), maxSize: CGSizeMake(your label width,999)) 
let labelHeight = labelSize.height 

atama labelHeight.