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

    }

Thank you Enjoy it.



Comments

Popular posts from this blog

Windows Keys

Important extensions while create a new App in swift

S.O.L.I.D. Principles with Example (Swift & Dart)