得到UIView中某个非子视图在UIView中的位置

使用 convertRect: fromView: 或者 convertRect: toView:
例如一个视图控制器的view中有一个UITableView,UITableView的某个cell中有个UITextField,想要得到UITextField在view中的位置,就要靠上面的两个方法了。

CGRect rect = [self.view convertRect:textField.framefromView:textField.superview];
或者
CGRect rect = [textField.superview convertRect:textField.frametoView:self.view];
进行转换都可以。

posted @ 2014-11-26 18:13  ZLK0011  阅读(102)  评论(0编辑  收藏  举报