Skip to content

Commit 1487927

Browse files
authored
Merge pull request #60 from ximximik/master
Fix min height calculation when change `font` and `textContainerInset`
2 parents d3f3cca + ce4789a commit 1487927

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

NextGrowingTextView/NextGrowingInternalTextView.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ internal class NextGrowingInternalTextView: UITextView {
3030
// MARK: - Internal
3131

3232
var didChange: () -> Void = {}
33+
var didUpdateHeightDependencies: () -> Void = {}
3334

3435
override init(frame: CGRect, textContainer: NSTextContainer?) {
3536
super.init(frame: frame, textContainer: textContainer)
@@ -58,6 +59,18 @@ internal class NextGrowingInternalTextView: UITextView {
5859
updatePlaceholder()
5960
}
6061
}
62+
63+
override var font: UIFont? {
64+
didSet {
65+
didUpdateHeightDependencies()
66+
}
67+
}
68+
69+
override var textContainerInset: UIEdgeInsets {
70+
didSet {
71+
didUpdateHeightDependencies()
72+
}
73+
}
6174

6275
var placeholderAttributedText: NSAttributedString? {
6376
didSet {

NextGrowingTextView/NextGrowingTextView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,9 @@ open class NextGrowingTextView: UIScrollView {
162162
_textView.didChange = { [weak self] in
163163
self?.fitToScrollView()
164164
}
165+
_textView.didUpdateHeightDependencies = { [weak self] in
166+
self?.updateMinimumAndMaximumHeight()
167+
}
165168
}
166169

167170
private func measureTextViewSize() -> CGSize {

0 commit comments

Comments
 (0)