Commit c5136171 by Orkhan Alikhanov

Added animation to textView height change

parent 84e574ef
...@@ -263,12 +263,6 @@ open class TextView: UITextView { ...@@ -263,12 +263,6 @@ open class TextView: UITextView {
layoutShape() layoutShape()
layoutShadowPath() layoutShadowPath()
layoutPlaceholderLabel() layoutPlaceholderLabel()
guard isGrowEnabled else {
return
}
invalidateIntrinsicContentSize()
} }
/** /**
...@@ -290,10 +284,32 @@ open class TextView: UITextView { ...@@ -290,10 +284,32 @@ open class TextView: UITextView {
preparePlaceholderLabel() preparePlaceholderLabel()
} }
open override var contentSize: CGSize {
didSet {
guard isGrowEnabled else {
return
}
invalidateIntrinsicContentSize()
guard isEditing && isHeightChangeAnimated else {
superview?.layoutIfNeeded()
return
}
UIView.animate(withDuration: 0.15) {
self.superview?.layoutIfNeeded()
}
}
}
/// A Boolean that indicates if the height change during growing is animated.
open var isHeightChangeAnimated = true
/// Maximum preffered layout height before scrolling. /// Maximum preffered layout height before scrolling.
open var preferredMaxLayoutHeight: CGFloat = 0 { open var preferredMaxLayoutHeight: CGFloat = 0 {
didSet { didSet {
invalidateIntrinsicContentSize() invalidateIntrinsicContentSize()
superview?.layoutIfNeeded()
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment