问题描述
我注意到,StatusBar组件(React Native)没有支持包含本文档中任何类型的图标或徽标的道具:
对于iOS,无法在状态栏中添加任何自定义图标,而Apple不允许.
对于Android,您应该使用Notification and Notification Manager.只需用Java编写一个本机模块,然后在启动应用程序时执行此操作.React Native允许您调用用Java编写的Native Module,在这里看看 https://facebook.github.io/react-native/docs/native-modules-android.html
对于通知
I have noticed that there is no props for the StatusBar component (React Native) to include an icon or logo of any kind as in this documentation:https://facebook.github.io/react-native/docs/statusbar.html#statusbar
I would like for an icon (or even just a small widthxheight square) to appear next to the networks bar continuously while the app is running in the background. I tried combining the View component with the status bar to create a small red rectangle like this:
<View style={styles.container}>
<StatusBar
backgroundColor="blue"
barStyle="light-content"
/>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
width: 20,
height: 20,
backgroundColor: 'red'
}
})
However the red square just appeared below the status bar. Any ideas?
Edit:What I want is to have my app logo on the status bar even when the app is in the background. (apps that provide VPN and location services do this sometimes).
For iOS it's not possible to add any custom icons in the status bar, apple doesn't allow it.
For Android you should use Notification and Notification Manager. Just write a native module in java who do this when your app is launching.React Native allow you to call Native Module written in Java, take a look here https://facebook.github.io/react-native/docs/native-modules-android.html
You should also read this for Notification How to show an icon in the status bar when application is running, including in the background?
这篇关于如何将图标(图像,徽标..)添加到状态栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!