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

来源:互联网 发布:linux怎么向上翻页 编辑:程序博客网 时间:2024/06/05 02:49

http://blog.sina.com.cn/s/blog_8764c3140100xfo7.html


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

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

0 0
原创粉丝点击