gpt4 book ai didi

ios - 动画完成 Action

转载 作者:行者123 更新时间:2023-11-28 20:03:54 24 4
gpt4 key购买 nike

我有以下代码来显示和隐藏 uiview,但是在隐藏显示和我第二次显示它时它非常不稳定。我希望仅在动画完成后才隐藏显示。我读过一些我们可以在 xcode 中做到这一点的文章,但是我不确定我会怎么做?

  -(IBAction)modal:(id)sender{


if (self.optionsuiview.hidden == YES)
{
[UIView animateWithDuration:0.2 animations:^{
CGRect f = self.optionsuiview.frame;
f.origin.x = 0;
f.origin.y = 42;
self.optionsuiview.frame = f;
}];


self.optionsuiview.hidden = NO;
}
else
{

[UIView animateWithDuration:0.2 animations:^{
CGRect f = self.optionsuiview.frame;
f.origin.x = 0;
f.origin.y = 0;
self.optionsuiview.frame = f;


// self.optionsuiview.hidden = YES;

}];


self.optionsuiview.hidden = YES;
}
}

最佳答案

使用其中之一animation methods ,例如:

[UIView animateWithDuration:duration animations:^{
// your animation code here
} completion:^(BOOL finished) {
// call after animation is complete
}];

关于ios - 动画完成 Action ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22809585/

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