zoukankan      html  css  js  c++  java
  • React Native 获取组件(Component)在屏幕上的位置

    年后主客户端的需求以及老的业务迁移RN,现在疯狂的在学RN。在迁移需求的时候遇到需要获取组件在屏幕上的绝对位置。页面如下:

    就需要展开的时候获取sectionHeader(默认排序)在屏幕上的具体位置,核心代码如下:

    renderSectionHeaderContent() {
            return (
                <SectionHeader
                    ref={(sectionHeader) => { this.sectionHeader = sectionHeader; }}
    
                    title={this.state.sectionHeaderTitle}
                    clickSectionHeader={() => {
                        const handle = findNodeHandle(this.sectionHeader);
                        UIManager.measure(handle, (x, y, width, height, pageX, pageY) => {
                           
                        });
                    }}
                />
            );
        }

    注:需要 import { UIManager} from 'NativeModules';   x、y:为视图的相对位置。width、height:为视图的宽度和高度。pageX、pageY为视图在屏幕上的绝对位置。

    ================================================================

    初学React Native 。若有疑问请加本人QQ:610774281 微信:stephenli225。 一起探讨一起进步。。。。

  • 相关阅读:
    (转)消息队列 Kafka 的基本知识及 .NET Core 客户端
    Neo4j学习笔记
    科技论文推荐系统
    下载pubmed数据
    杂项
    Scrapy 知乎验证码
    Scrapy 爬取网站文章
    爬虫基础知识
    Django linux uWsgi Nginx 部署
    DocumentSimilarity
  • 原文地址:https://www.cnblogs.com/lidaojian/p/6735087.html
Copyright © 2011-2022 走看看