2017-10-18 72 views
0

我使用react-native,我想改變主動段按鈕的風格,我有這樣的代碼:反應原生:如何改變活動部分的風格?

import { Segment } from "native-base"; 

<Segment style={{backgroundColor: '#222'}}> 
     <Button bending style={{width: '50%', height: '100%',borderColor: '#222'}}> 
     <Text>Bending</Text> 
     </Button> 
     <Button history style={{width: '50%', height: '100%',borderColor: '#222'}}> 
     <Text>History</Text> 
     </Button> 
    </Segment> 

當任何按鈕sellected,我想它的風格:

borderBottomColor: 'red' 

我該怎麼辦?

回答

0

建立一個國家來管理,然後點擊使用樣式這樣

<Button bending 
    style={(this.state.selectedButton == "bending") // condition to add dynamic selector 
    ? styles.selectedButtonStyle // with red color 
    : buttonStyle} // normal style 
> 
+0

你可以寫用例,請語法選按鈕,並更新,因爲我是一個begginner –