【发布时间】:2020-05-10 02:47:06
【问题描述】:
我的 react native 应用中有一个简单的 TextInput。以下是相关代码:
<View style={styles.AmountWrapper}>
<TextInput
multiline={true}
placeholder="$0"
placeholderTextColor={colors.black38}
style={styles.NumberInput}
keyboardType={"numeric"}
/>
</View>
let styles = StyleSheet.create({
AmountWrapper: {
flexDirection: "column",
flex: 1,
alignItems: "center",
justifyContent: "center",
backgroundColor: colors.white
},
NumberInput: {
flexDirection: "row",
alignItems: "center",
flex: 0,
fontFamily: styleHelper.fontFamily("medium"),
fontSize: 48,
paddingHorizontal: 16,
paddingTop: 0,
paddingBottom: 0,
color: colors.blue,
textAlign: "center",
borderWidth: 0,
textAlignVertical: "center"
},
});
我正在使用 Android 9.0 和 Xcode 的模拟器模拟 iOS 12.4 iPhone X 的 Android Studio Pixel 3。
在 Android 上,这正是我想要的效果:
问题在于 iOS。它使文本太高了,切断了美元符号的顶部,以及数字的几个像素。它使用占位符和当用户输入文本时这样做:
我尝试过更改边距、填充、textAlign、lineHeight、flexDirection、alignItems 和 justifyContent。我还在 TextInput 中尝试过 multiline={false}。
如何让 iOS 进一步向下渲染文本并在 TextInput 中正确显示?
【问题讨论】:
-
用尽所有其他选项后,字体文件本身似乎存在问题。不确定到底是什么问题,但其他字体不会产生这个问题。 Android 没有问题,但 iOS 有。
标签: ios react-native textinput