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;
舉個??
UITableViewCell中某一個label的frame轉(zhuǎn)換到controller中
// controller 中有一個UITableView, UITableView里有多行UITableVieCell惠奸,cell上放有一個UILabel
// 在controller中實現(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