W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
style View#style
'use strict';var React = require('react-native');var { StyleSheet, TabBarIOS, Text, View, } = React;var TabBarExample = React.createClass({ statics: { title: '<TabBarIOS>', description: 'Tab-based navigation.' }, getInitialState: function() { return { selectedTab: 'redTab', notifCount: 0, presses: 0, }; }, _renderContent: function(color: string, pageText: string) { return ( <View style={[styles.tabContent, {backgroundColor: color}]}> <Text style={styles.tabText}>{pageText}</Text> <Text style={styles.tabText}>{this.state.presses} re-renders of the More tab</Text> </View> ); }, render: function() { return ( <TabBarIOS> <TabBarIOS.Item title="Blue Tab" selected={this.state.selectedTab === 'blueTab'} onPress={() => { this.setState({ selectedTab: 'blueTab', }); }}> {this._renderContent('#414A8C', 'Blue Tab')} </TabBarIOS.Item> <TabBarIOS.Item systemIcon="history" badge={this.state.notifCount > 0 ? this.state.notifCount : undefined} selected={this.state.selectedTab === 'redTab'} onPress={() => { this.setState({ selectedTab: 'redTab', notifCount: this.state.notifCount + 1, }); }}> {this._renderContent('#783E33', 'Red Tab')} </TabBarIOS.Item> <TabBarIOS.Item systemIcon="more" selected={this.state.selectedTab === 'greenTab'} onPress={() => { this.setState({ selectedTab: 'greenTab', presses: this.state.presses + 1 }); }}> {this._renderContent('#21551C', 'Green Tab')} </TabBarIOS.Item> </TabBarIOS> ); }, });var styles = StyleSheet.create({ tabContent: { flex: 1, alignItems: 'center', }, tabText: { color: 'white', margin: 50, }, });module.exports = TabBarExample;
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: