美文网首页
RN中获取View的位置

RN中获取View的位置

作者: 偶然中的必然 | 来源:发表于2019-05-23 15:47 被阅读0次
<View ref="test" style={[styles.item, {}]}></View>
const handle = findNodeHandle(this.refs.test);

UIManager.measureInWindow(handle, (x, y, width, height) => {
     console.log('绝对位置x', x);
     console.log('绝对位置y', y);
     console.log('组件宽度', width);
     console.log('组件高度', height);
 })

UIManager.measure(handle ,(x, y, width, height, X, Y) => {
     console.log('相对父视图位置x', x);
     console.log('相对父视图位置y', y);
     console.log('组件宽度', width);
     console.log('组件高度', height);
     console.log('绝对位置x', X);
     console.log('绝对位置y', Y);
 })
import {
    findNodeHandle,
    UIManager
} from 'react-native'

相关文章

网友评论

      本文标题:RN中获取View的位置

      本文链接:https://www.haomeiwen.com/subject/bjcbzqtx.html