You should use a UITextView instead of a UITextField .
Then you can use the sizeThatFits method.
But first you need to know what one line will be. You can get this information with lineHeight :
var amountOfLinesToBeShown: CGFloat = 6 var maxHeight: CGFloat = yourTextview.font.lineHeight * amountOfLinesToBeShown
After that, just call the sizeThatFits method inside your viewDidLoad method and set maxHeight ( line * 6 ) as the height of your textview:
yourTextview.sizeThatFits(CGSizeMake(yourTextview.frame.size.width, maxHeight))
Christian
source share