0.3.3 • Published 6 years ago

react-native-status-bar-size v0.3.3

Weekly downloads
449
License
MIT
Repository
github
Last release
6 years ago

react-native-status-bar-height

Watch and respond to changes in the iOS status bar height.

Add it to your project

  1. Run npm install react-native-status-bar-size --save
  2. Follow the example below to use it in JS

Deprecated change Event

The change event has been deprecated. The didChange event should be used instead. It's still available but may be removed in a later version.

Example

var MyApp = React.createClass({
   getInitialState: function() {
     return {
       currentStatusBarHeight: StatusBarSizeIOS.currentHeight,
     };
   },

   componentDidMount: function() {
     StatusBarSizeIOS.addEventListener('willChange', this._handleStatusBarSizeWillChange);
     StatusBarSizeIOS.addEventListener('didChange', this._handleStatusBarSizeDidChange);
   },

   componentWillUnmount: function() {
     StatusBarSizeIOS.removeEventListener('willChange', this._handleStatusBarSizeWillChange);
     StatusBarSizeIOS.removeEventListener('didChange', this._handleStatusBarSizeDidChange);
   },

   _handleStatusBarSizeWillChange: function(nextStatusBarHeight) {
     console.log('Will Change: ' + nextStatusBarHeight);
   },

   _handleStatusBarSizeDidChange: function(currentStatusBarHeight) {
     console.log('changed');
     this.setState({ currentStatusBarHeight: currentStatusBarHeight });
   },

   render: function() {
     return (
       <View style={{flex: 1, backgroundColor: 'white', justifyContent: 'center', alignItems: 'center'}}>
         <Text>Current status bar height is: {this.state.currentStatusBarHeight}</Text>
       </View>
     );
   },
});

Demo gif

0.3.3

6 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.1

8 years ago

0.2.0

9 years ago

0.1.0

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago