2

I am using TTTAttributedLabel and UIFont(name: "HelveticaNeue-Medium", size: 12.0) now. To get height string, i made this function.

self.font = UIFont(name: "HelveticaNeue-Medium", size: 12.0)

let constraintRect = CGSize(width: CGFloat(self.width!), height: CGFloat.max)
let boundingBox = self.strCurrent!.boundingRectWithSize(constraintRect, options: NSStringDrawingOptions.UsesLineFragmentOrigin, attributes: [NSFontAttributeName:self.font!], context: nil)

return boundingBox.height

I have one problem, this function is working well about short string. but About long string(more than 100 lines), this function cant get correct height, so I cant see full string at UILabel. How can i get correct height? Thanks

zhang
  • 21
  • 3

0 Answers0