坐标点转换

2017-09-06  本文已影响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

上一篇下一篇

猜你喜欢

热点阅读