首页指南参考教程

Expo SystemUI

GitHub

npm

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

Android
iOS
tvOS
Web

expo-system-ui 使你能够与 React 树之外的 UI 元素进行交互。特别是根视图背景颜色,并在 Android 上全局锁定用户界面样式。

¥**expo-system-ui** enables you to interact with UI elements that fall outside of the React tree. Specifically the root view background color, and locking the user interface style globally on Android.

安装

¥Installation

Terminal
npx expo install expo-system-ui

If you're installing this in a bare React Native app, you should also follow these additional installation instructions.

API

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

Methods

SystemUI.getBackgroundColorAsync()

Gets the root view background color.

Example

const color = await SystemUI.getBackgroundColorAsync();

Returns

  • Promise<ColorValue | null>

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

SystemUI.setBackgroundColorAsync(color)

NameTypeDescription
colornull | ColorValue

Any valid CSS 3 (SVG) color.


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

Example

SystemUI.setBackgroundColorAsync("black");

Returns

  • Promise<void>

Expo 中文网 - 粤ICP备13048890号