UIView中的坐标转换
2014-02-24 19:40
323 查看
// 将像素point由point所在视图转换到目标视图view中,返回在目标视图view中的像素值 - (CGPoint)convertPoint:(CGPoint)point toView:(UIView *)view; // 将像素point从view中转换到当前视图中,返回在当前视图中的像素值 - (CGPoint)convertPoint:(CGPoint)point fromView:(UIView *)view; // 将rect由rect所在视图转换到目标视图view中,返回在目标视图view中的rect - (CGRect)convertRect:(CGRect)rect toView:(UIView *)view; // 将rect从view中转换到当前视图中,返回在当前视图中的rect - (CGRect)convertRect:(CGRect)rect fromView:(UIView *)view; 例把UITableViewCell中的subview(btn)的frame转换到 controllerA中 // controllerA 中有一个UITableView, UITableView里有多行UITableVieCell,cell上放有一个button // 在controllerA中实现: CGRect rc = [cell convertRect:cell.btn.frame toView:self.view]; 或 CGRect rc = [self.view convertRect:cell.btn.frame fromView:cell]; // 此rc为btn在controllerA中的rect 或当已知btn时: CGRect rc = [btn.superview convertRect:btn.frame toView:self.view]; 或 CGRect rc = [self.view convertRect:btn.frame fromView:btn.superview];
相关文章推荐
- 【最小生成树】ZOJ 2966 Build The Electric System
- uva 1252 - Twenty Questions(记忆化搜索)
- IE访问Form Builder网站的碰到的几个问题
- Form Builder 代码汇编一:表单当前所有记录输出到CSV文件
- HDU 4390 Number Sequence ---容斥原理
- rpmbuild打包错误记录
- ios学习:UINavigationController导航
- java中break和continue的使用与区别
- 694 - The Collatz Sequence
- 解决 “invalid deployment target '5.0.0' for architecture 'arm64' (requires '7.0.0' or later)”
- 手机GUI自动化测试介绍
- Android中UI线程与后台线程交互设计的5种方法
- Codeforces 392C Yet Another Number Sequence
- [IOS]使用UIScrollView和UIPageControl显示半透明帮助蒙板
- 使用本地通知UILocalNotification实现简易闹钟
- Android UI详解之Fragment加载
- pcDuino 2.8″USB显示屏
- [已解决]CSRF verification failed. Request aborted. CSRF token missing or incorrect.
- UVA 11324 The Largest Clique(SCC+DP)
- Android Call requires API level 11 (current min is 8)的解决方案