React native 所需文本字段的样式(反应原生材质文本字段)

React native 所需文本字段的样式(反应原生材质文本字段),react-native,React Native,如何设置自定义样式,以便用户可以看到,该字段是必需的。 我想到一颗红星,或者标签文本不是灰色而是红色。 我怎么做这个 谢谢你的支持。 Rene不需要单独设置标签或文本字段的样式,您可以使用react native material textfield提供的属性。我建议您使用以下属性并实现UI上看起来很酷的属性 label- put label to textfeild title- put required as a title to textfeild prefix- prefix you

如何设置自定义样式,以便用户可以看到,该字段是必需的。 我想到一颗红星,或者标签文本不是灰色而是红色。 我怎么做这个

谢谢你的支持。
Rene

不需要单独设置标签或文本字段的样式,您可以使用react native material textfield提供的属性。我建议您使用以下属性并实现UI上看起来很酷的属性

label- put label to textfeild

title- put required as a title to textfeild

prefix- prefix your textfeild with required label

suffix- suffix your textfeild with required label

error- provide error proper error message when empty or as per you requirement 

errorColor- here you can put a red color to show that its a required feild

characterRestriction put character restrictions

labelTextStyle style the label

titleTextStyle style the title
或者你可以使用一些方法

focus()     Acquire focus 

blur()  Release focus

clear()     Clear text field

value()     Get current value   

isFocused()     Get current focus state     

isRestricted()  Get current restriction state 
由于您没有提供代码,我已经为您提供了cuztomize文本字段的基本步骤。
希望这有帮助,你可以走了

请按以下方式使用


感谢您的回复。我知道这个描述。labelTextStyle不起作用。我的字体颜色一直是灰色的…另一种我没有设置的样式-仅labelTextStyle={styles.required}。。。必需:{color:colors.required,}。。。必需:'rgb(218、41、28)'