Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我试图解决的场景是我有几个 UIViews 作为主 UIView 的子视图。我想要做的是突出显示一个视图矩形,让我们说当手指在视图上滑动时更改它的边框......类似于将鼠标光标移动/拖动到超文本链接上时发生的情况。
您可以在touchesMoved:方法中获取触摸的位置,然后询问主 UIView 触摸了哪个视图:
touchesMoved:
- (void)touchesMoved: (NSSet *)touches withEvent:(UIEvent *)event { UIView *subview = [masterView hitTest:[[touches anyObject] locationInView:masterView] withEvent:nil]; ... }