我正在尝试处理 UIButton 动画,其中按钮移动到一个点,然后将隐藏设置为 true。然而,当我尝试使用以下代码时,该按钮甚至在动画完成之前就消失了。我做得正确吗?有什么建议吗?
[UIView animateWithDuration:0.8
animations:^{
selectedCurveIndex = 0;
[tradebutton moveTo:
CGPointMake(51,150) duration:0.8
option:curveValues[UIViewAnimationOptionCurveEaseInOut]];
}
completion:^(BOOL finished){
[tradeButton setHidden:TRUE];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"ButtonView"];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentModalViewController:vc animated:NO];
}];
最佳答案
在继续之前,您需要确保将完成设置为是。
您的按钮隐藏得很快,因为 0.8 是一个很快的动画持续时间。您需要找到另一个位置来隐藏该按钮,或者您可以
试试这个:
[UIView animateWithDuration:0.8
animations:^{
selectedCurveIndex = 0;
[tradebutton moveTo:
CGPointMake(51,150) duration:0.8
option:curveValues[UIViewAnimationOptionCurveEaseInOut]];
}
completion:^(BOOL finished){
if ( finished )
{
[tradeButton performSelector:@selector(setHidden:) withObject:@"YES" afterDelay:3.0];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"ButtonView"];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentModalViewController:vc animated:NO];
}
}];
关于ios - UIButton 动画问题 - iOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11642143/