【问题标题】:TextInput underline color for ios in react-nativereact-native中ios的TextInput下划线颜色
【发布时间】:2017-12-18 03:33:01
【问题描述】:

我正在为 android 和 ios 做 react-native 的移动应用程序。 在我的项目中,我使用的是 TextInput Component(ios)。该组件不带下划线。如何在 ios 中使用带有下划线颜色的 TextInput。

代码示例 -

<TextInput
 ref={'cardbatch1'}                 
 keyboardType = 'numeric'
 placeholder = 'Batch Number'
 autoCapitalize = 'none'                                                    
/>

【问题讨论】:

  • 请提供最小的工作示例。

标签: ios react-native underline


【解决方案1】:

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

const styles = StyleSheet.create({

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

最后在textInput中添加样式

<TextInput
 ...             
 keyboardType = 'numeric'
 placeholder = 'Batch Number'
 autoCapitalize = 'none'
 style={styles.inputBox}
.....                                                    
/>

【讨论】:

    【解决方案2】:

    您可以将borderBottomWidth 和borderBottomColor 添加到TextInput 或简单地在TextInput 下方绘制一个高度为1 或2 px 的视图。

    【讨论】:

    • 谢谢..我会选择borderBottomWidth和borderBottomColor。
    • 这在 android 中不起作用。如何在android中制作
    • 安卓使用:underlineColorAndroid="transparent"
    猜你喜欢
    • 2019-01-10
    • 2019-02-03
    • 1970-01-01
    • 2019-03-03
    • 1970-01-01
    • 2019-09-28
    • 2020-01-23
    • 2020-03-12
    • 2022-10-13
    相关资源
    最近更新 更多