TextInput为react-native中的ios加下划线颜色

Sat*_*ram 9 underline ios react-native

我正在为Android和ios做反应原生的移动应用程序.在我的项目中,我正在使用TextInput Component(ios).此组件显示没有下划线.如何在ios中使用带下划线颜色的TextInput.

代码示例 -

<TextInput
 ref={'cardbatch1'}                 
 keyboardType = 'numeric'
 placeholder = 'Batch Number'
 autoCapitalize = 'none'                                                    
/>
Run Code Online (Sandbox Code Playgroud)

Irf*_*yaz 24

您可以将borderBottomWidth和borderBottomColor添加到TextInput,或者只是在TextInput下绘制1或2像素高度的视图.


Rez*_*rim 5

在样式中试试这个..看看输出的差异

const styles = StyleSheet.create({

    inputBox: {
        .....
        borderBottomWidth: 1,
        borderBottomColor: 'gray',
        ....
    }
});
Run Code Online (Sandbox Code Playgroud)

最后在textInput中添加样式

<TextInput
 ...             
 keyboardType = 'numeric'
 placeholder = 'Batch Number'
 autoCapitalize = 'none'
 style={styles.inputBox}
.....                                                    
/>
Run Code Online (Sandbox Code Playgroud)