我尝试创建一个具有特定样式的按钮。 我有超过3个属性,如justifyContent,alignItems,backgroundColor和height。我想将一个样式从另一个组件传递给它,这样按钮的backgroundColor属性就会改变。
我的代码:
int hack(int *);
typedef int (*hackFunction)(int *);
int _main(hackFunction hack)
这里,buttonStyle不会应用于按钮,而只会应用backgroundColor prop。有什么帮助吗?
感谢。
答案 0 :(得分:10)
如果您想同时使用样式对象和内联样式中的样式,请将它们放在如下数组中:
<TouchableOpacity style={[buttonStyle, {backgroundColor: csCode }]}>
...
</TouchableOpacity>