UIView中的坐标转换
2016-06-29 14:16
471 查看
IOS-- UIView中的坐标转换
// 将像素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];
相关文章推荐
- ios UILabel在storyBoard或xib中如何在每行文字不显示完就换行
- 在Bluemix 使用OpenWhisk 开发Dark Vision应用系统
- 85-002-15 利用EasyUI设计一个后台页面的菜单显示
- Leetcode-unique-binary-search-trees
- AYUI快速开发2016-6-29 ,全部免费,WPF普遍之路梦想开启
- GitHub user guide:Hello world
- [绍棠]iOS开发-UITableViewCell(UICollectionViewItem)需要两个手指点击或者长按才可以选中,解决办法
- LeetCode 307 Range Sum Query - Mutable(范围和查询-可变)
- 85-002-13 基于EasyUI搭建前端页面的后台
- 85-002-10 在web项目中使用RequestAware接口
- fuel8安装过程简单回顾
- UITableView回调和table相关成员方法详解
- EasyUi的ComboBox(下拉列表框)
- android studio 的 Gradle build finished with 1 error(s) 问题
- 使用照相机或者相册
- 【UI】【View】MotionEvent类详解
- ios上 更改 状态栏(UIStatusBar)的颜色
- UIAlertController简单使用
- Access restriction: The method 'CharacterEncoder.encode(byte[])' is not API (restriction on required
- Request.getparameternames 获取form表单里面所有的请求参数 。 返回一个Enumeration类型的枚举.