convertPoint直接示例,把A上的點轉換到B上:
[A convertPoint:point toView:B];
[B convertPoint:point fromView:A];
注意:point坐標的參考系是A視圖,A和B的視圖層次不需要關系。
convertRect直接示例,把A的frame轉換到B上:
[A convertRect:A.bounds toView:B];
[B convertRect:A.bounds fromView:A];
注意:rect需要相對于A(同上一樣,bounds就是A相對于自身的frame),A和B的視圖層次不需要關系。
總結:
A視圖轉換某個位置(point或者frame)到B視圖上,則point或者frame必須是參考A視圖作為坐標系。
B視圖把某個位置(point或者frame)轉換到自身,這個位置是來自于A視圖,則point或者frame必須是參考A視圖作為坐標系。
一個意思兩種表達方式,實質是一樣,關鍵理清要轉換的point或者frame正確的參考系。
看完之后可以測試,加深理解!如有其它問題,歡迎指正。