属性
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;作者:terry,如若转载,请注明出处:https://www.web176.com/reactnative/22049.html
支付宝
微信