From 4df14158c70d625c66b39d85d632706294d60384 Mon Sep 17 00:00:00 2001 From: Anton Plebanovich Date: Fri, 11 Mar 2022 04:39:22 +0300 Subject: [PATCH] - COntent size category change layout fix --- Sources/GrowingTextView/GrowingTextView.swift | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Sources/GrowingTextView/GrowingTextView.swift b/Sources/GrowingTextView/GrowingTextView.swift index 2c41470..3cfec7c 100644 --- a/Sources/GrowingTextView/GrowingTextView.swift +++ b/Sources/GrowingTextView/GrowingTextView.swift @@ -83,6 +83,15 @@ open class GrowingTextView: UITextView { private var oldText: String = "" private var oldSize: CGSize = .zero + open override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) { + super.traitCollectionDidChange(previousTraitCollection) + + if previousTraitCollection?.preferredContentSizeCategory != traitCollection.preferredContentSizeCategory { + oldSize = .zero + setNeedsLayout() + } + } + private func forceLayoutSubviews() { oldSize = .zero setNeedsLayout()