![](/img/trans.png)
[英]Capturing touches on a subview outside the frame of its superview (over multiple layers)
[英]Touches on a subview outside the frame of its superview
需要帮忙。
在超级视图框架之外创建菜单。 menu=[[MyView alloc]initWithFrame:CGRectMake(0, -100, 320, 100)];
当菜单移到屏幕上时,超级视图也会移动。
-(void)openMenu:(UIView *)view
{
[UIView animateWithDuration:0.5
delay:0.1
options: UIViewAnimationOptionBeginFromCurrentState
animations:^
{
CGRect frame = menu.frame;
CGRect viewFrame = view.frame; //superview
frame.origin.y=-80;
viewFrame.origin.y=65;
menu.frame = frame;
view.frame = viewFrame;
}
completion:^(BOOL finished)
{
}];}
菜单有5个按钮。
问题在于他们不响应触摸事件。 我读过有必要替换: hitTest:withEvent:
但是我不知道该怎么做。
谢谢!
我找到了解决方案。 需要增加窗口范围。 用view.bounds
替换了view.frame
view.bounds
。 问题在于触摸事件在窗口范围之外没有响应。
谢谢大家!
PS对不起,我的英语!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.