iOS-- UIView中的坐标转换
2015-11-16 13:09
609 查看
// 将像素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];
相关文章推荐
- AndroidStudio使用备忘:报错finished with non-zero exit value 2
- UITableView的reloadData方法,不执行cellForRow方法,
- karaf配置自定义featrues
- UIViewContentMode各类型效果
- HTML特殊标签介绍(如:marquee标签)
- Range Sum Query 2D - Immutable My Submissionsstion-leetcode
- UIScrollViewDelegate - scrollViewDidEndDecelerating
- EasyUI TreeGrid
- UILabel minimum font size告警
- Lucene系列-DocValues
- Longest Consecutive Sequence
- 使用Druid对SQL执行情况进行监控,以及SQL注入等的检查
- 详解IBM Bluemix端到端开发体验
- Field "state" doesn't have a default value
- 利用Druid实现应用和SQL监控
- iOS开发UI篇-懒加载
- 蓝牙连接的uuid
- bzoj 4010 菜肴制作|拓扑排序|priority_queue|解题思想
- bzoj 1029 建筑抢修|贪心|priority_queue
- GPUimage 遇到的崩溃及问题