刚开始探索 iOS SDK。我有一些按钮,需要突出显示它们一次触摸外部然后拖动。据我了解,当您单击按钮然后向外拖动然后再次向内拖动时,会触发 TouchDragEnter 事件。当您在按钮外部单击然后拖动到内部时是否会触发任何事件?
最佳答案
亚历山大,
搜索相同的信息时,我发现您的问题没有得到解答。您可能已经弄清楚了,但我是这样做的。
请注意 pointInside:withEvent: 方法检查点是否位于按钮的边界内。由于触摸事件来自 View ,因此您必须将其转换为按钮的坐标系。
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
for (UITouch *t in touches) {
CGPoint touchPoint = [t locationInView:self.view];
CGPoint testPoint = [self.view convertPoint:touchPoint toView:aButton];
if ([aButton pointInside:testPoint withEvent:event]) {
//Do something
}
//rest of code
关于ios - 拖动进入时突出显示按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7938445/