@react-native-community/blur
普遍效果的组件 视图对iOS的模糊和活泼效应,以及 模糊视图 安卓号.
当前维护者 :
- 马尔布兰切岛 (单位:千美元)推特@titozzz从 布莱加德
内容
安装
yarn add @react-native-community/blur
安装本地依赖( 只有iOS) :
cd ios && pod install
使用量
模糊视图
| 财产 | 可能值 | 默认 | 平台 |
|---|---|---|---|
blurType | 参见下面的模糊类型 | - 说吧 | 全体 |
blurAmount | 0-100 (Android上最大模糊的Amount是32,因此更高的值会被夹入到32) | 10个 | 全体 |
reducedTransparencyFallbackColor | 任何颜色 | - 说吧 | 仅iOS |
blurRadius | 0 - 25岁 | 匹配 iOS 模糊的挂载 | 只有机器人 |
downsampleFactor | 0 - 25岁 | 匹配 iOS 模糊的挂载 | 只有机器人 |
overlayColor | 任何颜色 | 基于 iOS 模糊的默认颜色Type | 只有机器人 |
模糊类型
| 名称 | 说明 |
|---|---|
xlight | 额外光线模糊类型 |
light | 光线模糊类型 |
dark | 黑暗模糊类型 |
extraDark | 额外暗模糊类型( 只有 tvOS) |
regular | 常规模糊类型(仅iOS 10+和tvOS) |
prominent | 突出的模糊类型(仅iOS 10+和tvOS) |
模糊类型( 仅iOS 13)
| 名称 | 说明 |
|---|---|
chromeMaterial | 一种可适应的模糊效应,产生系统铬的外观. |
material | 一种可适应的模糊效应,产生出具有正常厚度的材料外观. |
thickMaterial | 一种可适应的模糊效应,产生出比平时更厚的材料外观. |
chromeMaterial | 一种可适应的模糊效应,产生系统铬的外观. |
thinMaterial | 一种可适应的模糊效应,产生出超薄材料的外观. |
ultraThinMaterial | 一种可适应的模糊效应,产生出超薄材料的外观. |
chromeMaterialDark | 一种模糊的影响,它制造出超薄材料的外表,并且总是阴暗. |
materialDark | 一种模糊的效应,它制造出薄材料的外观,并且总是阴暗. |
thickMaterialDark | 一种模糊的效果,它产生出一种具有正常厚度的材料的外观,并且总是阴暗. |
thinMaterialDark | 模糊效应,产生出一种比平时更厚并总是阴暗的物质外表. |
ultraThinMaterialDark | 一种模糊的效应,它产生系统铬的外观,并且总是阴暗. |
chromeMaterialLight | 一种可适应的模糊效应,产生系统铬的外观. |
materialLight | 一种可适应的模糊效应,产生出具有正常厚度的材料外观. |
thickMaterialLight | 一种可适应的模糊效应,产生出比平时更厚的材料外观. |
thinMaterialLight | 一种可适应的模糊效应,产生薄材料的外观. |
ultraThinMaterialLight | 一种可适应的模糊效应,产生出超薄材料的外观. |
在iOS和Android上工作的完整用法示例:
import React, { Component } from "react";
import { View, Image, Text, StyleSheet } from "react-native";
import { BlurView } from "@react-native-community/blur";
export default function Menu() {
return (
<View style={styles.container}>
<Image
key={'blurryImage'}
source={{ uri }}
style={styles.absolute}
/>
<Text style={styles.absolute}>Hi, I am some blurred text</Text>
{/* in terms of positioning and zIndex-ing everything before the BlurView will be blurred */}
<BlurView
style={styles.absolute}
blurType="light"
blurAmount={10}
reducedTransparencyFallbackColor="white"
/>
<Text>I'm the non blurred text because I got rendered on top of the BlurView</Text>
</View>
)
}
const styles = StyleSheet.create({
container: {
justifyContent: "center",
alignItems: "center"
},
absolute: {
position: "absolute",
top: 0,
left: 0,
bottom: 0,
right: 0
}
});
在这个例子中 Image 组件将模糊,因为 BlurView 位于顶部。 不过 Text 将保持无忧无虑.
如果无障碍环境 Reduce Transparency 已启用 BlurView 将使用 reducedTransparencyFallbackColor 因为它是背景颜色而不是模糊。 如果没有 reducedTransparencyFallbackColor 提供BlurView将使用默认倒置颜色(白色、黑色或灰色,取决于 blurType(中文(简体) )
振动维尤
使用与 BlurView (单位:千美元)blurType, (中文(简体) ), blurAmount,以及 reducedTransparencyFallbackColor) (中文(简体) ).
振动效应让模糊的视野下的内容 通过更生动的显示
VibrancyView is only supported on iOS. Also note that the VibrancyView must contain nested views
import { VibrancyView } from "@react-native-community/blur";
export default function Menu() {
return (
<Image source={{ uri }} style={styles.absolute}>
<VibrancyView blurType="light" style={styles.flex}>
<Text>Hi, I am some vibrant text.</Text>
</VibrancyView>
</Image>
)
}
实例反应原生应用程序
这个项目包括一个React Industrial app的例子,它被用来在此README中制作GIF. 您可以按照这些步骤运行应用程序 :
清除仓库
git clone https://github.com/react-native-community/react-native-blur.git
安装依赖关系
yarn
运行应用程序
yarn example android/ios
有问题吗?
随便你 创建问题