坐標(biāo)點(diǎn)轉(zhuǎn)換
- (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的坐標(biāo)點(diǎn)p1轉(zhuǎn)化為相對(duì)于toview的坐標(biāo)點(diǎn)----下面作用相同
[fromview convertPoint:p1 toView:toView];
[toview convertPoint:p1 fromView:fromView];
如果obj是nil,則返回zero
如果參數(shù)view是nil,則toview會(huì)自動(dòng)當(dāng)作window來(lái)對(duì)待。
如果fromview/toview的superview是nil,fromview/toview沒(méi)有被addsubview,則可能發(fā)生異常。
1, 有共同的superview
2,互為父子/孫子。。關(guān)系
3,有共同的祖先supview