How can I set textview height according to your text in swift 4
If you want to increases you textview height according to your text then do following steps.
Create Hieght object
Like:-
@IBOutlet var consTxtdescHeight: NSLayoutConstraint!
func setTextViewHeight()
{
let fixedWidth = txtDesc.frame.size.width
txtDesc.sizeThatFits(CGSize(width: fixedWidth, height: CGFloat.greatestFiniteMagnitude))
let newSize = txtDesc.sizeThatFits(CGSize(width: fixedWidth, height: CGFloat.greatestFiniteMagnitude))
var newFrame = txtDesc.frame
newFrame.size = CGSize(width: max(newSize.width, fixedWidth), height: newSize.height)
consTxtdescHeight.constant = newFrame.height
}
Comments
Post a Comment