Q群 567530369,小伙伴们都在这里等你哦~

SegmentedControlIOS

使用SegmentedControlIOS来在iOS设备上渲染一个UISegmentedControl组件。这是一个分段显示多个选项的组件。

Programmatically changing selected index

The selected index can be changed on the fly by assigning the selectedIndex prop to a state variable, then changing that variable. Note that the state variable would need to be updated as the user selects a value and changes the index, as shown in the example below.

Example

<SegmentedControlIOS
  values={['One', 'Two']}
  selectedIndex={this.state.selectedIndex}
  onChange={(event) => {
    this.setState({selectedIndex: event.nativeEvent.selectedSegmentIndex});
  }}
/>

查看Props


文档

Props

enabled

If false the user won't be able to interact with the control. Default value is true.

类型必填
bool


momentary

If true, then selecting a segment won't persist visually. The onValueChange callback will still work as expected.

类型必填
bool


onChange

Callback that is called when the user taps a segment; passes the event as an argument

类型必填
function

onValueChange

Callback that is called when the user taps a segment; passes the segment's value as an argument

类型必填
function

selectedIndex

The index in props.values of the segment to be (pre)selected.

类型必填
number

tintColor

Accent color of the control.

类型必填
string


values

The labels for the control's segment buttons, in order.

类型必填
array of string