我正在开发一个应用程序,当我按下菜单按钮时,IBAction 会创建一个覆盖(添加子视图)。此子视图必须包含必须可访问的按钮。我最初犯了一个错误,将额外的按钮添加到前一个视图中。因此,当我按下菜单按钮时,新的覆盖层会弹出,额外的按钮无法访问。有什么建议吗?我是 iOS 编程的新手。谢谢
- (IBAction) btnMoveTo:(id)sender
{
UIButton* button= (UIButton*)sender;
[self overlayCheck];
[movingButton setHidden:false];
[movingButton2 setHidden:false];
[movingButton3 setHidden:false];
[movingButton moveTo:
CGPointMake(125,250) duration:0.8
option:curveValues[selectedCurveIndex]];
[movingButton2 moveTo:
CGPointMake(25,250) duration:0.8
option:curveValues[selectedCurveIndex]];
[movingButton3 moveTo:
CGPointMake(225,250) duration:0.8
option:curveValues[selectedCurveIndex]];
}
-(void)overlayCheck{
CGRect frame = [homeButton frame];
UIView* view = [[UIView alloc] initWithFrame:CGRectMake(frame.origin.x - FrameSizeIncreaseAmount, frame.origin.y - FrameSizeIncreaseAmount, frame.size.width + FrameSizeIncreaseAmount * 2, frame.size.height + FrameSizeIncreaseAmount * 2)];
view.backgroundColor = [UIColor blackColor];
[self.view addSubview:view];
[UIView beginAnimations:@"fade in" context:nil];
[UIView setAnimationDuration:0.2];
[view setBackgroundColor:[[UIColor grayColor] colorWithAlphaComponent:MaxAlpha]];
[UIView commitAnimations];
}
应该在新视图上的movingButton、movingButton2 和movingButton3。叠加层不允许我访问按钮。