From 616fc928aa91e9f630957c015ad634739c0ea63d Mon Sep 17 00:00:00 2001 From: keisukeYamagishi Date: Fri, 22 Feb 2019 15:21:06 +0900 Subject: [PATCH 1/2] fix addedto end of text --- Sources/ReadMoreTextView.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Sources/ReadMoreTextView.swift b/Sources/ReadMoreTextView.swift index 071f1b4..3f9c459 100644 --- a/Sources/ReadMoreTextView.swift +++ b/Sources/ReadMoreTextView.swift @@ -198,7 +198,7 @@ public class ReadMoreTextView: UITextView { public override var intrinsicContentSize : CGSize { textContainer.size = CGSize(width: bounds.size.width, height: CGFloat.greatestFiniteMagnitude) var intrinsicContentSize = layoutManager.boundingRect(forGlyphRange: layoutManager.glyphRange(for: textContainer), in: textContainer).size - intrinsicContentSize.width = UIView.noIntrinsicMetric + intrinsicContentSize.width = UIViewNoIntrinsicMetric intrinsicContentSize.height += (textContainerInset.top + textContainerInset.bottom) intrinsicContentSize.height = ceil(intrinsicContentSize.height) return intrinsicContentSize @@ -272,15 +272,14 @@ public class ReadMoreTextView: UITextView { shouldTrim = false textContainer.maximumNumberOfLines = 0 - if let originalAttributedText = _originalAttributedText?.mutableCopy() as? NSMutableAttributedString { - attributedText = _originalAttributedText + if let originalAttributedText = _originalAttributedText?.mutableCopy() as? NSMutableAttributedString { let range = NSRange(location: 0, length: text.unicodeScalars.count) if let attributedReadLessText = attributedReadLessText { originalAttributedText.append(attributedReadLessText) } textStorage.replaceCharacters(in: range, with: originalAttributedText) } - + attributedText = _originalAttributedText invalidateIntrinsicContentSize() invokeOnSizeChangeIfNeeded() } From 2df28e759114c536debc32bc33df9c2df463a451 Mon Sep 17 00:00:00 2001 From: keisukeYamagishi Date: Fri, 22 Feb 2019 17:43:04 +0900 Subject: [PATCH 2/2] Delete unnecessary empty line change --- Sources/ReadMoreTextView.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Sources/ReadMoreTextView.swift b/Sources/ReadMoreTextView.swift index 3f9c459..0b9c0ee 100644 --- a/Sources/ReadMoreTextView.swift +++ b/Sources/ReadMoreTextView.swift @@ -279,6 +279,7 @@ public class ReadMoreTextView: UITextView { } textStorage.replaceCharacters(in: range, with: originalAttributedText) } + attributedText = _originalAttributedText invalidateIntrinsicContentSize() invokeOnSizeChangeIfNeeded()