react-native - React Native SwitchSelector 在选择时更改图标颜色
问题描述
import React from "react";
import { StatusBar, StyleSheet } from "react-native";
import { Fontisto } from "@expo/vector-icons";
import SwitchSelector from "react-native-switch-selector";
const options = [
{ label: "M", value: "M", customIcon: <Fontisto name="male" size={20} /> },
{ label: "F", value: "F", customIcon: <Fontisto name="female" size={20} /> },
];
<SwitchSelector
options={options}
initial={0}
selectedColor={"#ffffff"}
borderColor={"#cccccc"}
buttonColor={"#539670"}
onPress={(value) => console.log(`Call onPress with value: ${value}`)}
selectedTextContainerStyle={{ color: "#ffffff" }}
borderWidth="2"
/>;
以上代码未在选项选择上更新图标颜色需要更改图标颜色文本颜色更改工作但图标颜色未更新。
解决方案
<SwitchSelector
// textColor="red"
selectedColor="yellow"
buttonColor="#800000"
borderColor="blue"
hasPadding
initial={0}
borderRadius={20}
//onPress={value => setGender({gender: value})}
//options={genderOptions}
options={[
{
label: 'Male',
value: 'm',
imageIcon: require('../images/male.png'),
},
{
label: 'FeMale',
value: 'f',
imageIcon: require('../images/female.png'),
},
]}
/>
推荐阅读
- javascript - 如何阻止简单的 Discord 机器人 ping 用户?
- javascript - javascript transitionEnd 在 setInterval 一段时间后不起作用
- php - 如何根据字段在多个列表中显示查询结果?
- ios - “类 NSURLSession 上的未知类型名称 'tls_protocol_version_t'”
- lisp - SBCL - 循环函数中的“非法函数调用”
- c++ - 如何输出一个字符**
- excel - 如何使用 excel 电源查询附加双引号(“”)?
- python - 如何在模块中包含 *.py 以外的文件?
- graphviz - graphViz/dot:调整节点位置和边缘形状
- python - `hash -r 2` 有什么作用?