gpt4 book ai didi

iphone - UIView使用 block 动画方法滑入但不滑出动画

转载 作者:行者123 更新时间:2023-12-03 18:43:26 25 4
gpt4 key购买 nike

我有一个名为 geopointView 的 UIView。我想在按下按钮(myButton)时在主视图框架上的 UIview 中制作幻灯片动画。如果再次按下 myButton,UIview 应该滑出框架。 myButton 调用以下方法“optionsCalled”

-(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 函数时出现延迟?

感谢您提前提供的帮助

最佳答案

动画完成后尝试[geopointView removeFromSuperview];

关于iphone - UIView使用 block 动画方法滑入但不滑出动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7415736/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com