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));

  • 相关阅读:
    个人总结
    第二次冲刺 10
    第二次冲刺 09
    第二次冲刺 08
    第二次冲刺 07
    团队冲刺第七天
    团队绩效评估
    团队冲刺第六天
    团队冲刺第五天
    团队冲刺第四天
  • 原文地址:https://www.cnblogs.com/qitiandasheng/p/5486714.html
Copyright © 2011-2022 走看看