zoukankan      html  css  js  c++  java
  • ios坐标位置转换

    //ios常用坐标转换来处理一些下拉框队形的按钮的位置,我以最下面两个来进行一下个人的理解,不足之处多多见谅

    - (CGPoint)convertPoint:(CGPoint)point toView:(nullable UIView *)view;

    - (CGPoint)convertPoint:(CGPoint)point fromView:(nullable UIView *)view;

    - (CGRect)convertRect:(CGRect)rect toView:(nullable UIView *)view;

    - (CGRect)convertRect:(CGRect)rect fromView:(nullable UIView *)view;

    /*

      将当前的视图的frame 转换成到距离目标视图的距离,返回真实视图的距离

        rc值 = view.fram+rect

    */

      //view1为目标视图 self.view表示当前视图

        CGRect rect = CGRectMake(view1.frame.size.width/2, view1.frame.size.height, view1.frame.size.width, view1.frame.size.height);

           CGRect rc = [view2 convertRect:rect fromView:view1];

        view2.frame =rc;

      /*

         将当前的视图的frame 转换成到目标视图的距离 返回到目标位置的距离

         frame = rect -view.frame

        */

        CGRect rect = CGRectMake(200, 200, view1.frame.size.width, view1.frame.size.height);

        CGRect rc = [view2 convertRect:rect toView:view1];

        view2.frame =rc;

        NSLog(@"%@",NSStringFromCGRect(rc));

  • 相关阅读:
    ubuntu防火墙设置通过某端口
    pandas入门
    pyplot入门
    numpy教程
    跨域请求 spring boot
    spring boot 启动流程
    代理配置访问
    AOP,拦截器
    spring boot 启动不连接数据库
    Python 3.x 连接数据库(pymysql 方式)
  • 原文地址:https://www.cnblogs.com/qitiandasheng/p/5486714.html
Copyright © 2011-2022 走看看