Wednesday, November 4, 2026
HomeiOS DevelopmentMethods to set iOS standing bar background colour in React Native?

Methods to set iOS standing bar background colour in React Native?

[ad_1]

iOS would not have an idea of a standing bar bg. This is the way you’d obtain this in a cross-platform means:

import React, {
  Element,
} from 'react';
import {
  AppRegistry,
  StyleSheet,
  View,
  StatusBar,
  Platform,
  SafeAreaView
} from 'react-native';

const MyStatusBar = ({backgroundColor, ...props}) => (
  <View fashion={[styles.statusBar, { backgroundColor }]}>
    <SafeAreaView>
      <StatusBar translucent backgroundColor={backgroundColor} {...props} />
    </SafeAreaView>
  </View>
);

class DarkTheme extends Element {
  render() {
    return (
      <View fashion={kinds.container}>
        <MyStatusBar backgroundColor="#5E8D48" barStyle="light-content" />
        <View fashion={kinds.appBar} />
        <View fashion={kinds.content material} />
      </View>
    );
  }
}

const STATUSBAR_HEIGHT = StatusBar.currentHeight;
const APPBAR_HEIGHT = Platform.OS === 'ios' ? 44 : 56;

const kinds = StyleSheet.create({
  container: {
    flex: 1,
  },
  statusBar: {
    top: STATUSBAR_HEIGHT,
  },
  appBar: {
    backgroundColor:'#79B45D',
    top: APPBAR_HEIGHT,
  },
  content material: {
    flex: 1,
    backgroundColor: '#33373B',
  },
});

AppRegistry.registerComponent('App', () => DarkTheme);

simulator

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments