![](/img/trans.png)
[英]How do i customize the label in 'react-native-dropdown-picker'?
[英]Customize elements in react-native-dropdown-picker
React Native Dropdown Picker是在 React Native 中实现下拉列表的最流行的库。 但是在库中,我找不到自定义下拉列表中的下拉箭头和刻度的方法。 它们默认为黑色,据我所知无法自定义。
基本实现:
import DropDownPicker from 'react-native-dropdown-picker'; function App() { const [open, setOpen] = useState(false); const [value, setValue] = useState(null); const [items, setItems] = useState([ { label: 'ice-cream', value: '1' }, { label: 'strawberry', value: '2' }, { label: 'grapes', value: '3' }, { label: 'fruit salad', value: '4' }, { label: 'jello', value: '5' }, { label: 'apple', value: '6' }, ]); return ( <DropDownPicker open={open} value={value} items={items} setOpen={setOpen} setValue={setValue} setItems={setItems} /> ); }
示例 Output: [单击此处查看输出] 2
有一个道具叫做arrowIconStyle
。 但就此而言,我也找不到将颜色作为样式的方法。
例如: arrowIconStyle={{color: 'white'}}
Unfortunately this does not work and gives an error:
输入'{颜色:字符串; }' 不可分配给类型 'StyleProp'.ts(2322)
有人可以帮我解决这个问题吗?
谢谢你。
尝试更改箭头图标并为图标实现您自己的样式,如下所示: https ://snack.expo.dev/@hewr/57a779
//to change the dropdown box style
dropDownContainerStyle={{
backgroundColor: "#dfdfdf"
}}
// to style the selected item style
selectedItemContainerStyle={{
backgroundColor: "grey"
}}
有关详细信息,请访问他们的网站
并检查Dropdown和List and Items部分
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.