iOS 选项卡

属性

Edit on GitHub

style View#style

例子

Edit on GitHub

'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;


本内容均来自互联网,仅供参考,如有侵权请及时通知本站予以删除。邮箱:wiki#imooc.com (#改成@)

意见反馈 帮助中心 APP下载
官方微信