【问题标题】:How to override style in NativeBase?如何覆盖 NativeBase 中的样式?
【发布时间】:2016-08-02 09:59:25
【问题描述】:

NativeBase Docs 中提到的每个代码示例中,都没有使用 React StyleSheet。
我没有找到覆盖 NativeBase 样式的方法。
如何在我的应用中包含 React StyleSheet?

【问题讨论】:

  • 如果您认为文档没有更新/携带的信息较少,您也可以尝试提交问题here

标签: react-native native-base


【解决方案1】:

对于 NativeBase,通常如果您想要自定义外观,您需要在主题级别而不是组件/小部件级别进行。

http://nativebase.io/docs/v0.5.2/customize

我相信它保持 UI 一致的原因。

查看您尝试覆盖其样式的所有小部件的源代码:

https://github.com/GeekyAnts/NativeBase/blob/master/Components/Widgets/

在某些情况下,您可以修改某些方面,例如对于按钮 this.props.style 可在除this.props.textStyle 之外的任何地方使用

所以你可以在定义组件的时候覆盖textStyle:

<Button textStyle={{...}}/>

https://github.com/GeekyAnts/NativeBase/blob/master/Components/Widgets/Button.js

【讨论】:

    猜你喜欢
    • 2015-06-22
    • 2011-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-05
    • 2019-02-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多