+33
patches/react-native-uitextview+1.4.0.patch
+33
patches/react-native-uitextview+1.4.0.patch
···
1
+
diff --git a/node_modules/react-native-uitextview/ios/RNUITextViewShadow.swift b/node_modules/react-native-uitextview/ios/RNUITextViewShadow.swift
2
+
index c34ba71..13d576a 100644
3
+
--- a/node_modules/react-native-uitextview/ios/RNUITextViewShadow.swift
4
+
+++ b/node_modules/react-native-uitextview/ios/RNUITextViewShadow.swift
5
+
@@ -159,13 +159,23 @@ class RNUITextViewShadow: RCTShadowView {
6
+
let maxSize = CGSize(width: CGFloat(maxWidth), height: CGFloat(MAXFLOAT))
7
+
let textSize = self.attributedText.boundingRect(with: maxSize, options: .usesLineFragmentOrigin, context: nil)
8
+
9
+
- var totalLines = self.lineHeight == 0.0 ? 0 : Int(ceil(textSize.height / self.lineHeight))
10
+
-
11
+
- if self.numberOfLines != 0, totalLines > self.numberOfLines {
12
+
- totalLines = self.numberOfLines
13
+
+ var finalHeight: CGFloat
14
+
+
15
+
+ if self.numberOfLines != 0 && self.lineHeight != 0.0 {
16
+
+ // numberOfLines is set with custom line height - need to calculate lines and snap to lineHeight multiples
17
+
+ // NOTE: this calculation can be inaccurate with fractional font sizes
18
+
+ var totalLines = Int(ceil(textSize.height / self.lineHeight))
19
+
+ if totalLines > self.numberOfLines {
20
+
+ totalLines = self.numberOfLines
21
+
+ }
22
+
+ finalHeight = CGFloat(totalLines) * self.lineHeight
23
+
+ } else {
24
+
+ // Either no numberOfLines limit, or no custom lineHeight - use actual text height
25
+
+ // (numberOfLines without custom lineHeight is handled by the UITextView's textContainer.maximumNumberOfLines)
26
+
+ finalHeight = textSize.height
27
+
}
28
+
29
+
- self.frameSize = CGSize(width: CGFloat(maxWidth), height: CGFloat(CGFloat(totalLines) * self.lineHeight))
30
+
+ self.frameSize = CGSize(width: CGFloat(maxWidth), height: finalHeight)
31
+
return YGSize(width: Float(self.frameSize.width), height: Float(self.frameSize.height))
32
+
}
33
+