在REACT原生IOS本机代码中是否有一个地方可以修改以设置IOS状态栏背景 colored颜色 ?RCTRootView.m?

react native StatusBar component只支持backgroundColor,仅适用于Android.

百人组

我的目标是让状态栏 colored颜色 更暗.

推荐答案

iOS没有状态栏BG的概念.下面是如何以跨平台的方式实现这一点:

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

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

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

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

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

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

simulator

Ios相关问答推荐

在SWIFT中将圆角+透明背景从导入视频(.mp4)添加到导出视频(.mov)

如何在SwiftUI中扩展双击的可检测区域?

在带有可编码的SWIFT5中,可以轻松处理以美元符号开头的JSON密钥,例如$DATE";

SwiftUI - 搜索栏和导航标题之间的空间太大

如何制作支持不同语言的iOS应用

创建方案时运行 pod install 时出错

使用 SwiftUI 显示多个 VNRecognizedObjectObservation 边界框时偏移量错误

满足条件时 SwiftUI 动画背景 colored颜色 变化

.overlay 和 body 是什么 swift 概念

Swift 共享数据模型在页面之间进行通信.这个怎么运作

实现一个将块用作回调的方法

使用 AVAudioPlayer 播放声音

通过 iOS 创建和导出动画 gif?

Swift枚举继承

是否可以使用 sharedHTTPCookieStorage 为 UIWebView 手动设置 cookie?

@IBDesignable 崩溃代理

SwiftUI NavigationView navigationBarTitle LayoutConstraints 问题

如何在键盘上方添加工具栏?

如何从 UIPickerView 获取选定的值

如何使用 AFNetworking 设置超时