我有一个叫做geopointView的UIView。我想在按下按钮(myButton)时在主视图框架上在此UIview中为幻灯片添加动画。如果再次按下myButton,则UIview应该滑出框架。 myButton的调用下面的方法“optionsCalled”UIView动画滑入,但不滑出使用块动画方法
-(void) optionsCalled
{
if (![[self.view subviews] containsObject:geopointView] &&checkForGeopointViewAnimation ==0) {
[self.view addSubview:geopointView];
geopointView.frame = CGRectMake(0,430,320,30);
[UIView animateWithDuration:0.3f
animations:^{
geopointView.frame = CGRectMake(0, 350, 100, 80);
}
completion:^(BOOL finished){
checkForGeopointViewAnimation = 1 ;
}];
}
if ([[self.view subviews] containsObject:geopointView] && checkForGeopointViewAnimation ==1)
{
geopointView.frame = CGRectMake(0, 350, 100, 80);
[UIView animateWithDuration:0.3f
animations:^{
geopointView.frame = CGRectMake(0,430,320,30);
}
completion:^(BOOL finished){
checkForGeopointViewAnimation = 0 ;
}];
[geopointView removeFromSuperview];
}
}
这里checkForGeopointViewAnimation被定义为确保滑动进出没有一次叫一个全局变量。
此代码的问题在于,UIview以动画形式滑动,但不会动画滑出动作。它只是从主框架消失。我是否需要在这里使用任何时间,以便在添加和删除UIview函数时有延迟?
感谢提前
非常感谢,指出.. – alekhine
@amol_subhedar:请投赞成所有帮助你的答案,只是为了表示赞赏。 – visakh7