Last active
February 9, 2022 06:11
-
-
Save raygun101/3da0382f798e8f1d0b68fea66a6f539d to your computer and use it in GitHub Desktop.
Revisions
-
raygun101 revised this gist
Feb 9, 2022 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ import UIKit /// /// 🍰 Layered Cakewalk - UITextViewWithAutoLayout /// /// A UITextView that has an `intrinsicContentSize` equal to the content size. /// class UITextViewWithAutoLayout : UITextView -
raygun101 revised this gist
Feb 9, 2022 . 1 changed file with 5 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,10 @@ import UIKit /// /// 🍰 Layered Cakewalk - UITextViewWithAutoLayout /// /// A UITextView that has a `intrinsicContentSize` equal to the content size. /// class UITextViewWithAutoLayout : UITextView { -
raygun101 revised this gist
Feb 9, 2022 . 1 changed file with 6 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -19,16 +19,19 @@ class UITextViewWithAutoLayout : UITextView self.textContainerInset = .zero self.textContainer.lineFragmentPadding = 0 _observer = self.observe(\.contentSize, options: [.old, .new]) { view, change in if change.oldValue != change.newValue { view.invalidateIntrinsicContentSize() } } } override var intrinsicContentSize: CGSize { self.contentSize } } -
raygun101 revised this gist
Jan 20, 2022 . No changes.There are no files selected for viewing
-
raygun101 revised this gist
Jan 20, 2022 . No changes.There are no files selected for viewing
-
raygun101 created this gist
Jan 20, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ import UIKit class UITextViewWithAutoLayout : UITextView { required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } private var _observer: NSObjectProtocol? /// override init(frame: CGRect, textContainer: NSTextContainer?) { super.init(frame: frame, textContainer: textContainer) self.enablesReturnKeyAutomatically = true self.backgroundColor = .clear self.layoutMargins = .zero self.insetsLayoutMarginsFromSafeArea = false self.contentInset = .zero self.textContainerInset = .zero self.textContainer.lineFragmentPadding = 0 _observer = self.observe(\.contentSize) { view, change in view.invalidateIntrinsicContentSize() } } override var intrinsicContentSize: CGSize { self.sizeThatFits(CGSize(.greatestFiniteMagnitude)) } }