![](/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.