IOS-- UIView中的坐标转换
2016-04-04 19:28
369 查看
// 将像素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];
相关文章推荐
- UICollectionView用法补充(照片轮播墙)
- UDID、UUID+keychain
- 在Java8的foreach()中使用return/break/continue
- HDU 3279 Nth Largest Value
- Leetcode232. Implement Queue using Stacks[栈实现队列]
- ios--uitextfield动态限制输入的字数(解决方式)
- 3.30课·········Marquee标签
- Hive分析窗口函数之LAG,LEAD,FIRST_VALUE和LAST_VALUE
- CALayer 的基本概念和基本使用
- This certificate has an invalid issuer
- BlockingQueue队列学习
- 关于requirejs中的define的原理理解
- 【HDU 2604】 Queuing
- cryptoAPI接口(五)------------获取证书--演示 CryptUIDlgViewCertificate
- key-value store
- String StringBuilder StringBuffer
- package-query: requires pacman<4.3(solved)
- SQuirreL 连接 hive
- unix环境高级编程(第三版)中apue.h文件的配置问题
- Espresso自动化测试(十三)- UiAutomator2与Espresso的结合