I am using React Native .68.1 and I’m trying to set the custom StatusBar that I’ve found on SO. It does work, however, it only uses hex values (no alpha channel). How do I set it up to where the status bar has a 50% opaque background? Here is my Custom StatusBar:
import React from 'react';
import { Platform, StatusBar, View } from 'react-native'
import { useSafeAreaInsets } from 'react-native-safe-area-context';
const CustomStatusBar = (props: any) => {
const { backgroundColor, ...rest } = props;
const insets = useSafeAreaInsets()
const STATUS_BAR_HEIGHT = Platform.OS === 'ios' ? insets.top : StatusBar.currentHeight
return (
<View style={{ backgroundColor: backgroundColor, height: STATUS_BAR_HEIGHT }}>
<StatusBar translucent backgroundColor={backgroundColor} {...rest} />
</View>
)
}
export default CustomStatusBar
2
Answers
This is what was able to fix my issue:
This is the style that I used when it was called:
ive developed kindof same thing for adding opacity to my HEX values, its fairly simple:
basically you need to pass the HEX and also opacity in terms of
OPACITY_PERCENTAGES
.Hope it clears, feel free for doubts