美文网首页
坐标点转换

坐标点转换

作者: 我是小胡胡分胡 | 来源:发表于2017-09-06 11:59 被阅读11次

    坐标点转换

    
    - (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;
    
    
    //fromView的坐标点p1转化为相对于toview的坐标点----下面作用相同
    [fromview convertPoint:p1 toView:toView];
    [toview convertPoint:p1 fromView:fromView];
    
    
    如果obj是nil,则返回zero
    如果参数view是nil,则toview会自动当作window来对待。
    如果fromview/toview的superview是nil,fromview/toview没有被addsubview,则可能发生异常。
    
    

    1, 有共同的superview
    2,互为父子/孙子。。关系
    3,有共同的祖先supview

    相关文章

      网友评论

          本文标题:坐标点转换

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