CGRect newRect = [self.view.window convertRect:self.blueView.frame fromView:self.redView]; NSLog(@"%@", NSStringFromCGRect(newRect)); |
|
结果:2015-11-03 19:30:37.123 坐标系转换[24126:1322418] {{150, 150}, {100, 100}} |
|
CGRect newRect = [self.blueView convertRect:CGRectMake(-50, -100, 100, 100) fromView:self.redView]; NSLog(@"%@", NSStringFromCGRect(newRect)); |
|
结果:2015-11-03 19:57:35.062 坐标系转换[32304:1340927] {{-100, -150}, {100, 100}} |
// 将 CGRectMake(50, 50, 100, 100) 从 self.blueView 坐标系 转换为 self.greenView 坐标系 CGRect newRect = [self.blueView convertRect:CGRectMake(50, 50, 100, 100) toView:self.greenView] |
2015-11-03 20:08:47.985 坐标系转换[35697:1350289] {{150, 150}, {100, 100}} |
CGRect newRect = [self.blueView convertRect:CGRectMake(50, 50, 100, 100) toView:nil];
|
2015-11-03 20:12:23.510 坐标系转换[36797:1353910] {{200, 200}, {100, 100}} |