
屏幕亮度
@capacitor-community/screen-brightness
在iOS和Android设备上控制屏幕亮度的电容社区插件.
版本数
| 插件 | 电容 | 文档 |
|---|---|---|
| 8.x 电话 | 8.x 电话 | 读取 |
| 7.x 电话 | 7.x 电话 | 读取 |
| 6.x (单位:千美元) | 6.x (单位:千美元) | 读取 |
| 5.x 电话 | 5.x 电话 | 读取 |
| 4.x (中文(简体) ) | 4.x (中文(简体) ) | 读取 |
| 1.x 运算 | 3.x 运算 | 读取 |
安装
npm install @capacitor-community/screen-brightness
npx cap sync
配置
此插件不需要配置
使用量
import { ScreenBrightness } from '@capacitor-community/screen-brightness';
// Set the brightness:
const brightness = 0.5;
await ScreenBrightness.setBrightness({ brightness });
// Get the current brightness:
const {brightness: currentBrightness} = await ScreenBrightness.getBrightness();
API 密码
设置亮度(...)
setBrightness(options: SetBrightnessOptions) => Promise<void>
设置亮度级别。 在iOS上,它设置了系统级别亮度,在Android上,它设置了当前视图的亮度.
| 参数 | 类型 | 说明 |
|---|---|---|
options | SetBrightnessOptions | 设置亮度的选项 |
自: 1.0.0 (单位:千美元)
获取亮度( )
getBrightness() => Promise<GetBrightnessReturnValue>
返回信息而不是包含当前亮度级别
- @ 自 1. 0
回返情况: Promise<GetBrightnessReturnValue>
接口
设置亮度选项
| Prop | 类型 | 说明 | 自兹 |
|---|---|---|---|
brightness | number | 将亮度设置为从 0.0( 非常暗)到 1.0( 完全亮度) 的级别 在Android上,将值设置为-1恢复用户配置的亮度. | 1.0.0 (单位:千美元) |
获得光速返回值
| Prop | 类型 | 说明 | 自兹 |
|---|---|---|---|
brightness | number | 当前亮度水平,从0.0(非常暗)到1.0(完全亮度) 在Android上,如果该应用没有更改值,则返回 -1 . | 1.0.0 (单位:千美元) |