UIView中的坐标转换
2015-11-23 10:15
344 查看
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 UI 规范
- Android Build with Gradle and ProGuard : “The output jar must be specified after an input jar, or it
- Run Configuration error:broken configuration due to unavailable
- int, NSInteger, NSUInteger, NSNumber的区别
- QT Creator 使用 design 修改 ui界面编译后界面未更新问题的解决 From EricQu
- UITextView的使用详解
- Kibana User Guide [4.2] » Visualize » Line Charts
- UILabel属性
- LeetCode "Range Sum Query 2D - Mutable"
- iOS子线程操作UI问题检查
- Array Question 1 unique string
- Android中子线程中更新UI的N中方法
- UVA 11775 Unique Story(DP)
- Cocoapods的pod install出现的某个错误 but they required a higher minimum deployment target.
- fastcgi_finish_request() 正确使用方式
- uitableview的空白处不能响应 touchesbegan 事件
- 【转载】COM 组件设计与应用(二)——GUID 和 接口
- android面试题 包括UI控件及数据存储内容
- iOS setValuesForKeysWithDictionary
- iOS:自定义模态动画 --UIPresentationController