gpt4 book ai didi

ios - 在动画中移动 UIView 时隐藏它

转载 作者:行者123 更新时间:2023-11-29 04:09:04 25 4
gpt4 key购买 nike

我有一些动画使用 beginAnimations 进行一些旋转。我想隐藏有问题的 UIview,当然我尝试更改隐藏属性但没有任何反应。这是代码

 CGAffineTransform rotation = CGAffineTransformMakeRotation( angelToRotate(-90));
[UIView beginAnimations: @"" context: NULL];
self.view.hidden = TRUE;
[UIView setAnimationDuration: 0.4];
self.view.transform = CGAffineTransformConcat(self.view.transform, rotation);
self.view.hidden = FALSE;
[UIView commitAnimations];

我也尝试更改 View 上的 Alpha,但仍然没有任何效果。

有什么想法吗?

最佳答案

CGAffineTransform rotation = CGAffineTransformMakeRotation( angelToRotate(-90));   
[UIView animateWithDuration:0.4 animations:^
{
self.view.transform = CGAffineTransformConcat(self.view.transform, rotation);
self.view.alpha = 0.0;
}
completion:^(BOOL finished)
{
self.view.alpha = 1.0;
}];

或者:


CGAffineTransform rotation = CGAffineTransformMakeRotation( angelToRotate(-90));
[UIView beginAnimations:nil context: NULL];
[UIView setAnimationDuration:0.4];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
self.view.transform = CGAffineTransformConcat(self.view.transform, rotation);
self.view.alpha = 0.0;
[UIView commitAnimations];

- (void) animationDidStop: (NSString *) animationID finished: (NSNumber *) finished context: (void *) context
{
self.view.alpha = 1.0;
}

关于ios - 在动画中移动 UIView 时隐藏它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14696850/

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