iOS 状态栏

保留所有版权。

源代码是在 BSD-style 许可下经过许可的,是在源代码树的根目录下的LICENSE 文件里找到的。额外授予的专利权可以在同目录下的 PATENTS 文件里找到。

@flow

方法

static setStyle(style: number, animated?: boolean)

static setHidden(hidden: boolean, animation: number)

例子

Edit on GitHub

  1. 'use strict';
  2. var React = require('react-native');
  3. var {
  4. StyleSheet,
  5. View,
  6. Text,
  7. TouchableHighlight,
  8. StatusBarIOS,
  9. } = React;
  10. exports.framework = 'React';
  11. exports.title = 'StatusBarIOS';
  12. exports.description = 'Module for controlling iOS status bar';
  13. exports.examples = [{
  14. title: 'Status Bar Style',
  15. render() {
  16. return (
  17. <View>
  18. {Object.keys(StatusBarIOS.Style).map((key) =>
  19. <TouchableHighlight style={styles.wrapper}
  20. onPress={() => StatusBarIOS.setStyle(StatusBarIOS.Style[key])}>
  21. <View style={styles.button}>
  22. <Text>setStyle(StatusBarIOS.Style.{key})</Text>
  23. </View>
  24. </TouchableHighlight>
  25. )}
  26. </View>
  27. );
  28. },
  29. }, {
  30. title: 'Status Bar Style Animated',
  31. render() {
  32. return (
  33. <View>
  34. {Object.keys(StatusBarIOS.Style).map((key) =>
  35. <TouchableHighlight style={styles.wrapper}
  36. onPress={() => StatusBarIOS.setStyle(StatusBarIOS.Style[key], true)}>
  37. <View style={styles.button}>
  38. <Text>setStyle(StatusBarIOS.Style.{key}, true)</Text>
  39. </View>
  40. </TouchableHighlight>
  41. )}
  42. </View>
  43. );
  44. },
  45. }, {
  46. title: 'Status Bar Hidden',
  47. render() {
  48. return (
  49. <View>
  50. {Object.keys(StatusBarIOS.Animation).map((key) =>
  51. <View>
  52. <TouchableHighlight style={styles.wrapper}
  53. onPress={() => StatusBarIOS.setHidden(true, StatusBarIOS.Animation[key])}>
  54. <View style={styles.button}>
  55. <Text>setHidden(true, StatusBarIOS.Animation.{key})</Text>
  56. </View>
  57. </TouchableHighlight>
  58. <TouchableHighlight style={styles.wrapper}
  59. onPress={() => StatusBarIOS.setHidden(false, StatusBarIOS.Animation[key])}>
  60. <View style={styles.button}>
  61. <Text>setHidden(false, StatusBarIOS.Animation.{key})</Text>
  62. </View>
  63. </TouchableHighlight>
  64. </View>
  65. )}
  66. </View>
  67. );
  68. },
  69. }];
  70. var styles = StyleSheet.create({
  71. wrapper: {
  72. borderRadius: 5,
  73. marginBottom: 5,
  74. },
  75. button: {
  76. backgroundColor: '#eeeeee',
  77. padding: 10,
  78. },
  79. });