Objective c 如何设置与presentModalViewController工作相同的UIView动画(即[self-presentModalViewController:child animated:YES];)
我是ios开发的新手,现在我正在我的应用程序上做一些动画。在我的应用程序中,在主视图的底部有一个菜单,有两个按钮,一个用于隐藏菜单,另一个用于显示菜单。我需要的是菜单的显示和隐藏功能就像Objective c 如何设置与presentModalViewController工作相同的UIView动画(即[self-presentModalViewController:child animated:YES];),objective-c,animation,uiview,xcode4,ios4,Objective C,Animation,Uiview,Xcode4,Ios4,我是ios开发的新手,现在我正在我的应用程序上做一些动画。在我的应用程序中,在主视图的底部有一个菜单,有两个按钮,一个用于隐藏菜单,另一个用于显示菜单。我需要的是菜单的显示和隐藏功能就像 [自我呈现ModalViewController:menuView动画:是]和[自我解除ModalViewController激活:是]功能(即,单击“显示”按钮,从主视图底部弹出菜单视图,然后单击“隐藏”按钮,向下移动菜单视图)。我知道一些基本的动画,比如: [UIView beginAnimations:@
[自我呈现ModalViewController:menuView动画:是]代码>和[自我解除ModalViewController激活:是]代码>功能(即,单击“显示”按钮,从主视图底部弹出菜单视图,然后单击“隐藏”按钮,向下移动菜单视图)。我知道一些基本的动画,比如:
[UIView beginAnimations:@"ShowHideView" context:nil];
[UIView setAnimationCurve:UIViewAnimationOptionOverrideInheritedCurve];
[UIView setAnimationDuration:1.0];
[UIView setAnimationDelegate:self];
[menuView setAlpha:0];
[UIView commitAnimations];
如果有人知道,请帮助我。当您点击showMenuView时,请执行以下操作:
- (IBAction)showView:(id)sender
{
[self.view addSubview: menuView];
CGRect rect = menuView.frame;
rect.origin.y = 480;
menuView.frame = rect;
[UIView beginAnimations:@"ShowView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.5];
rect.origin.y = 0;
menuView.frame = rect;
[UIView commitAnimations];
}
为了隐藏
- (IBAction)hideView:(id)sender
{
CGRect rect = menuView.frame;
[UIView beginAnimations:@"HideView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
rect.origin.y = 480;
menuView.frame = rect;
[UIView commitAnimations];
}
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
[menuView removeFromSuperview];
}
显示和隐藏视图必须显示不同的视图或相同的视图相同的视图(即menuView)嗨@Aadhira,您的解决方案是完美的。设置视图动画时,我希望禁用父视图的交互,并在其上显示一个透明层。怎么做