(一)背景透明字體透明
react-native背景使用opacity設(shè)置透明度,字體也透明問題
example: {
background: ‘#ffffff’,
opacity: 0.1
}
若使用上面樣式 字體也會(huì)透明
則使用下面這種寫法可解決
example: {
background: rgba(255,255,255,0.1)
}
(二)模糊組件
import { BlurView } from "@react-native-community/blur";
安裝@react-native-community/blur
安裝及參考鏈接 https://www.5axxw.com/wiki/content/t1h4nk
<BlurView style={[styles.viewModal]} blurType="light" blurAmount={10} />
寫在你想模糊的view的下方且同級?blurAmount為0-100直接 表示模糊度 android上如果小于1則會(huì)閃退 所以一般要寫大于1
(三)text.toUpperCase()輸入小寫轉(zhuǎn)成大寫
(四)調(diào)起手機(jī)震動(dòng)
iOS導(dǎo)入import ReactNativeHaptic from 'react-native-haptic';
android導(dǎo)入 import { Vibration } from 'react-native';
if(Platform.OS === 'ios'){
? ? ? ReactNativeHaptic.generate('impact');
}else {
? ? ? const pattern = [0,20,0,0];
? ? ? ? Vibration.vibrate(pattern,false);
}
(五)標(biāo)紅顯示關(guān)鍵字
https://github.com/haipingzi/react-native-markKeyWord/blob/master/index.js
react-native 巧用正則 和split() 在Text組件標(biāo)紅顯示關(guān)鍵字