iOS开发--UIView中的坐标转换
2016-03-01 18:17
591 查看
// 将像素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];
相关文章推荐
- 【Wunder Fund Round 2016 (Div 1 + Div 2 combined)B】【暴力 贪心】Guess the Permutation 全排列a[i][j]=min(p[i],p
- 使用Autolayout实现UITableView的Cell动态布局和高度动态改变
- UIButton上下结构垂直居中
- IOS(UI)_Block代码块
- POJ 1679 The Unique MST(次小生成树)
- Guice 学习(六)使用Provider注入服务( Provider Inject Service)
- require.js学习笔记1
- 详解 RN 中的 require()
- UGUI源码学习之初涉Image(一)
- UVa——540Team Queue(STL练习map、queue数组的综合使用)
- LA 2678(p48)----Subsequence
- android 自定义属性的使用一、在res/values文件下定义一个attrs.xml文件,代码如下
- IOS上关于状态栏的相关设置(UIStatusBar)
- java LinkedBlockingQueue源码简析
- SystemUI->截屏
- 手机客户端UI测试常见的测试点
- UITableView使用注意事项(unable to dequeue a cell with identifier)
- UIViewAnimationCurve 知识点
- androidStuido快捷键
- 1242 Rescue BFS