感谢您提供有用的建议,最终问题出在视图层次结构上,这被证明是有用的:
- (void)sendSubviewToBack:(UIView *)view
为了更清楚我想要实现的目标,我包含了一个视频来演示(注意我需要使用另一个视图来坐在我的主菜单按钮后面,以便滑动菜单在菜单按钮后面不部分可见,这是深灰色下半部分视图。我使用较深的灰色阴影来显示此视图的位置)
http://www.youtube.com/watch?v=nllXGh9sSls
这是我的一些代码,适用于可能有类似问题的任何人:
- (void) setupInterface {
//setting up the main button & the sliding button menu
[self addMyButton];
buttonMenu = [[ButtonMenu alloc] initWithFrame:(CGRectMake(100, 310, 120, 200)) ];
[self.view addSubview:buttonMenu];
[self.view sendSubviewToBack:buttonMenu];
}
- (void)MenuButtonClicked:(id)sender
{
[self rollOutIn]; //Call Flip BOOL
if (!rollOutMenuButton)
{
//pushing out the menu
buttonMenu.alpha = 0.0f;
[UIView beginAnimations:@"MoveView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:0.8f];
self.buttonMenu.frame = CGRectMake(100, 110, 120, 200);
buttonMenu.alpha = 1.0f;
[UIView commitAnimations];
}
else
{
//pulling the menu back in
[UIView beginAnimations:@"MoveView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:0.8f];
self.buttonMenu.frame = CGRectMake(100, 310, 120, 200);
buttonMenu.alpha = 0.0f;
[UIView commitAnimations];
}
}
希望这对其他人有所帮助:)