     static let textColor = UIColor.black()
 }
 
+// MARK: MessageComposerTextView
+
 class MessageComposerTextView: UITextView {
+    
+    private weak var heightConstraint: NSLayoutConstraint?
+    
+    private weak var minHeightConstraint: NSLayoutConstraint?
+    
+    private weak var maxHeightConstraint: NSLayoutConstraint?
+    
+    deinit {
+        removeNotification()
+    }
     
     override init(frame: CGRect, textContainer: NSTextContainer?) {
         super.init(frame: frame, textContainer: textContainer)
         setupViews()
+        setupConstraints()
+        addNotifications()
     }
     
     required init?(coder aDecoder: NSCoder) {
         super.init(coder: aDecoder)
         setupViews()
+        setupConstraints()
+        addNotifications()
+    }
+    
+    override func layoutSubviews() {
+        super.layoutSubviews()
+        
+        var height = self.sizeThatFits(self.frame.size).height
+        
+        if let maxHeightConstraint = self.maxHeightConstraint {
+            height = min(height, maxHeightConstraint.constant)
+        }
+        if let minHeightConstraint = self.minHeightConstraint {
+            height = max(height, minHeightConstraint.constant)
+        }
+        self.heightConstraint?.constant = height
     }
 }
 
-// MARK: - Private methods
+// MARK: Private methods
 
 private extension MessageComposerTextView {
     

        self.font = MessageComposerTextViewUX.font
        self.textColor = MessageComposerTextViewUX.textColor
        self.textAlignment = .natural
    }
}

//

import UIKit

// MARK: MessageComposerTextViewUX

struct MessageComposerTextViewUX {
    
