convertRect函数
- 显示蓝色
View
在黑色View
的坐标
UIView *baseView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
baseView.backgroundColor = [UIColor redColor];
UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 50, 50)];
topView.backgroundColor = [UIColor blueColor];
[self.view addSubview:baseView];
[baseView addSubview:topView];
// 两个都可以
CGRect rect = [self.view convertRect:topView.frame fromView:baseView];
CGRect rect = [baseView convertRect:topView.frame toView:self.view];
// rect = (150, 150, 50, 50);
convertPoint函数
有空再写