我如何获得一个不同的看法的触摸位置?
-
12-09-2019 - |
题
触摸可以指定自己得到触摸位置在其自己的坐标系统,但我如何从另一个得到它?说另一个的UIView的坐标系统?
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[UIView beginAnimations:@"box" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationBeginsFromCurrentState:YES];
UITouch *touch = [touches anyObject];
box.center = [touch locationInView:self];
[UIView commitAnimations];
}
莫非我但在不同的UIView其中“自我”是?
的名称解决方案
“此方法返回UITouch对象的指定视图的坐标系中的当前位置”,所以我说的是,可以在另一视图中通过。为了确保你能在你有两个视图重叠,NSLog的两次调用两种观点的结果的示例项目尝试。
不隶属于 StackOverflow