I\'m working on an application, in which I\'m required to autoresize the text area on basis of text to be displayed.
Firstly, I\'m not sure for this either I should use
You can change the size of label based on length of the string by, using this function
func ChangeSizeOfLabel(text:String) -> CGSize{
let font = UIFont(name: "HelveticaNeue", size: 12)!
let textAttributes = [NSFontAttributeName: font]
let size = text.boundingRectWithSize(CGSizeMake(310, 999), options: .UsesLineFragmentOrigin, attributes: textAttributes, context: nil)
let adjustSize = CGSizeMake(size.width, size.height)
return adjustSize
}
and use it like this :
let
showLabel.frame = CGRectMake(x, y, width , self.ChangeSizeOfLabel("Hello , Height is changing dynamically.....").height)