UIView的坐標(biāo)轉(zhuǎn)換
// 將point由point所在視圖轉(zhuǎn)換到目標(biāo)視圖view中,返回在目標(biāo)視圖view中的CGPoint
-(CGPoint)convertPoint:(CGPoint)point toView:(UIView *)view;
// 將point從view中轉(zhuǎn)換到當(dāng)前視圖中,返回在當(dāng)前視圖中的CGPoint
-(CGPoint)convertPoint:(CGPoint)point fromView:(UIView *)view;
// 將rect由rect所在視圖轉(zhuǎn)換到目標(biāo)視圖view中,返回在目標(biāo)視圖view中的CGRect
-(CGRect)convertRect:(CGRect)rect toView:(UIView *)view;
// 將rect從view中轉(zhuǎn)換到當(dāng)前視圖中,返回在當(dāng)前視圖中的CGRect
-(CGRect)convertRect:(CGRect)rect fromView:(UIView *)view;
舉個(gè)??
UITableViewCell中某一個(gè)label的frame轉(zhuǎn)換到controller中
// controller 中有一個(gè)UITableView, UITableView里有多行UITableVieCell,cell上放有一個(gè)UILabel
// 在controller中實(shí)現(xiàn):
- CGRect labelRect = [cell convertRect:cell.label.frame toView:self.view];
或- CGRect labelRect = [self.view convertRect:cell.label.frame fromView:cell];
// 此labelRect為label在controller中的CGRect