react-native获取组件在屏幕中相对位置以及视图宽高
- 引入模块
import { UIManager } from 'NativeModules';
import {findNodeHandle} from 'react-native';
2.获取写法
<View style={styles.tabBar} ref={(c) => { this.progressBar = c }} onLayout={() => {
const handle = findNodeHandle(this.progressBar);
setTimeout(()=>{UIManager.measure(handle, (x, y, width, height, pageX, pageY) => {
console.warn(x, y, width, height, pageX, pageY)
})},1000)
}}>