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

问题描述 投票:6回答:2

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

代码示例 -

<TextInput
 ref={'cardbatch1'}                 
 keyboardType = 'numeric'
 placeholder = 'Batch Number'
 autoCapitalize = 'none'                                                    
/>
ios react-native underline
2个回答
23
投票

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


3
投票

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

const styles = StyleSheet.create({

    inputBox: {
        .....
        borderBottomWidth: 1,
        borderBottomColor: 'gray',
        ....
    }
});

最后在textInput中添加样式

<TextInput
 ...             
 keyboardType = 'numeric'
 placeholder = 'Batch Number'
 autoCapitalize = 'none'
 style={styles.inputBox}
.....                                                    
/>
© www.soinside.com 2019 - 2024. All rights reserved.