我想在初始状态(不是 onFocus)调整概述的 react-native-paper TextInput 标签颜色。这是我的 OutlinedInput 组件:
import * as React from 'react';
import { TextInput } from 'react-native-paper';
const OutlinedInput = (props) => {
return (
<TextInput
mode='outlined'
label={props.label}
placeholder={props.placeholder}
placeholderTextColor='white'
secureTextEntry={props.secureTextEntry}
multiline={props.multiline}
keyboardType={props.keyboardType}
value={props.value}
onChangeText={(value) => props.onChangeText(value)}
style={props.style}
theme={props.theme}
/>
);
};
export default OutlinedInput;
在我的 Register 组件中,我在其中创建了一个 OutlinedInput 组件:
<View style={{ justifyContent: 'center', alignItems: 'center' }}>
<OutlinedInput
label={'User Name'}
value={userName}
onChangeText={(userName) => setUserName(userName)}
style={{ color: 'white', backgroundColor: 'rgb(35,39,42)',
borderRadius: 5, width: '75%', height: '5%'
}}
theme={{ colors: { text: 'white', primary: 'rgb(33, 151, 186)' } }}
/>
</View>
我在 Register 组件的顶部添加了这一行:
const [userName, setUserName] = useState('');
如果我不点击输入,我的程序截图:
这是单击输入的屏幕截图:
如您所见,标签用户名的颜色为黑色。我想将其设置为白色。单击它时,它按预期工作,但是标签颜色的初始状态不是我想要的。
我尝试使用占位符来解决这个问题。我在 OutlinedInput 中添加了占位符道具,并将占位符颜色更改为白色,但在这种情况下,占位符没有变成轮廓。当我尝试有关占位符的任何内容时,它并没有被概述。
打开程序后如何调整标签颜色以使其显示为白色?