IOS-- UIView中的坐标转换
2015-06-23 16:49
453 查看
// 将像素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];
- (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];
相关文章推荐
- QuickFIX/N入门:一、如何创建一个QuickFIX/N的应用程序
- QuickFIX/N入门:使用消息循环分组
- QuickFIX/N入门:如何自定义FIX
- mysql sequence
- UIScroll View 和 AutoLayout
- 8_Ueditor编辑器和Echarts的使用
- UE4 AI入门
- mysql:Variable 'character_set_client' can't be set to the value of 'NULL'解决
- Azure Queue队列存储(1)
- 使用SoapUI 对WebService压力测试
- easyui 本地js数据的加载
- iOS-给手势UITapGestureRecognizer添加"tag"标志
- easyui combotree的使用示例
- EasyUi细节
- How to fix Column 'InvariantName' is constrained to be unique 解决办法!
- easyui datagrid中图片的展示
- easyui treegrid的使用示例
- IOS键盘的相关设置(UITextfield)
- com.mysql.jdbc.PacketTooBigException: Packet for query is too large (2017898 > 1048576)
- duilib list 获取选中的行ID 获取行数 获取行指针 获取本行索引