Something went wrong. Try again.
Bluesky app fork with some witchin' additions 💫
Something went wrong. Try again.
1.7 kB · 35 lines
123456789101112131415161718192021222324252627282930313233343536diff --git a/ios/RNUITextViewShadow.swift b/ios/RNUITextViewShadow.swiftindex c34ba71..3602856 100644--- a/ios/RNUITextViewShadow.swift+++ b/ios/RNUITextViewShadow.swift@@ -159,13 +159,25 @@ class RNUITextViewShadow: RCTShadowView { let maxSize = CGSize(width: CGFloat(maxWidth), height: CGFloat(MAXFLOAT)) let textSize = self.attributedText.boundingRect(with: maxSize, options: .usesLineFragmentOrigin, context: nil) - var totalLines = self.lineHeight == 0.0 ? 0 : Int(ceil(textSize.height / self.lineHeight))-- if self.numberOfLines != 0, totalLines > self.numberOfLines {- totalLines = self.numberOfLines+ var finalHeight: CGFloat++ if self.numberOfLines != 0 && self.lineHeight != 0.0 {+ // numberOfLines is set with custom line height - need to calculate lines and snap to lineHeight multiples+ // NOTE: this calculation can be inaccurate with fractional font sizes+ var totalLines = Int(ceil(textSize.height / self.lineHeight))+ if totalLines > self.numberOfLines {+ totalLines = self.numberOfLines+ }+ finalHeight = CGFloat(totalLines) * self.lineHeight+ } else {+ // Either no numberOfLines limit, or no custom lineHeight - use actual text height+ // (numberOfLines without custom lineHeight is handled by the UITextView's textContainer.maximumNumberOfLines)+ finalHeight = textSize.height } - self.frameSize = CGSize(width: CGFloat(maxWidth), height: CGFloat(CGFloat(totalLines) * self.lineHeight))+ finalHeight = ceil(finalHeight)++ self.frameSize = CGSize(width: CGFloat(maxWidth), height: finalHeight) return YGSize(width: Float(self.frameSize.width), height: Float(self.frameSize.height)) }