ios - TextInput中的文本在ios上的位置不正确
问题描述
我有一个textInput
in a View
,它位于中心,使用flex
. 问题是,当您开始在 中书写时textInput
,文本会居中,即使我没有那样设置样式...
初始光标位于正确的位置,但一旦用户开始输入,文本就会居中。
奇怪的是,这个问题只发生在ios,而不是android...
我尝试添加样式textAlign: left
,但没有任何效果。我做错了什么,我该如何解决?
这是该项目的链接: https ://snack.expo.io/S1PlOqFvN
import React from 'react';
import { StyleSheet, Text, View, TextInput } from 'react-native';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<TextInput style={styles.textFieldStyling} placeholder="Try typing something..."></TextInput>
<Text style={styles.textStyling}></Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: 'orange',
alignItems: 'center',
justifyContent: 'center',
},
textStyling: {
fontSize: 50,
textAlign: 'center',
},
textFieldStyling: {
color: 'blue',
},
});
解决方案
React Native 中的 TextInput 没有关闭标签
<TextInput
style={styles.textFieldStyling}
placeholder="Try typing something..."
/>
推荐阅读
- java - 如何使用 JAVA 在 S3 文件中更新 CSV 文件的标题
- google-cloud-identity - API - 客户 ID 不容易找到 - 请支持 my_customer
- google-sheets-formula - 查找包含键的所有行并连接单元格值
- cordova - 离子文件插件在根内部存储上创建目录时出错
- html - CSS网格消除间隙
- python - 如何限制单个唯一 ID 可以拥有的行数?/文本游戏的有限游戏库存
- shell - Makefile:如何正确扩展 shell 函数中的变量?
- ios - Two different values from the same kSecAttrAccount in Keychain
- python - torch transform.resize() vs cv2.resize()
- linux - linux prevent user read other directory