Reference version

Expo SystemUI

一个允许与系统 UI 元素交互的库。

Android
iOS
Web
Bundled version:
~5.0.11

For the complete documentation index, see llms.txt. Use this Use this file to discover all available pages.

expo-system-ui 使你能够与超出 React 树范围的 UI 元素交互。具体来说,包括根视图背景颜色,以及在 Android 上全局锁定用户界面样式。

安装

Terminal
npx expo install expo-system-ui

If you are installing this in an existing React Native app, make sure to install expo in your project.

API

import * as SystemUI from 'expo-system-ui';

Methods

SystemUI.getBackgroundColorAsync()

Android
iOS
Web

Gets the root view background color.

Returns:
Promise<ColorValue | null>

Current root view background color in hex format. Returns null if the background color is not set.

Example

const color = await SystemUI.getBackgroundColorAsync();

SystemUI.setBackgroundColorAsync(color)

Android
iOS
Web
ParameterTypeDescription
colornull | ColorValue

Changes the root view background color. Call this function in the root file outside of your component.

Returns:
Promise<void>

Example

SystemUI.setBackgroundColorAsync("black");