iPhone:更改 CATransition 会导致 UIActivityIndicatorView 停止动画
当新视图推送到屏幕上时,我已经实现了非默认动画(请参见下面的代码)。由于某种原因,一旦我实现了这段代码,它就会导致我的 UIActivityIndicatorViews 停止工作。即使它们的 isAnimating 为 true,它们也会显示在屏幕上,但不会产生动画。我认为这是因为我更改了 CATransition,但无法弄清楚如何修复 UIActivityIndicatorView。
更改推送的默认动画
CATransition* fade = [CATransition animation];
fade.duration = 1.0;
fade.type = kCATransitionFade;
fade.subtype = kCATransitionFromTop;
[self.navigationController.view.layer
addAnimation:fade forKey:kCATransition];
稍后在 viewDidLoad 中
[spinner startAnimating];
我开始动画,但微调器将显示但不动画。由于某种原因,我的第一个旋转器有动画,但之后就没有了。
I have implemented a non-default animation for when a new view is pushed onto the screen (see code below). For some reason once I implemented this code it caused my UIActivityIndicatorViews to stop working. They will been shown on the screen but not animate even when their isAnimating is true. I figure it is because of me changing the CATransition, but can't figure out how to fix it for the UIActivityIndicatorView.
change default animation for push
CATransition* fade = [CATransition animation];
fade.duration = 1.0;
fade.type = kCATransitionFade;
fade.subtype = kCATransitionFromTop;
[self.navigationController.view.layer
addAnimation:fade forKey:kCATransition];
later on in viewDidLoad I start the animation
[spinner startAnimating];
but the spinner will show and not animate. For some reason the very first spinner I have animates but after that nothing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当我在 UINavigationController 的子类中使用 CATransition 来在推送或弹出视图控制器时具有自定义动画时,我遇到了这个问题。
在这个 UINavigationController 的子类的方法中,我有这样的代码:
但是,我后来发现你还必须将相同的动画添加到推送/弹出的 viewController 的视图层:
这个推送/弹出的视图控制器的视图是具有 UIActivityIndicatorView 的视图没有正确设置动画。
希望这有帮助!
I was encountering this problem when using a CATransition inside a subclass of UINavigationController to have a custom animation when pushing or popping view controllers.
Inside a method of this UINavigationController's subclass I had this code:
However, I later found out you also have to add the same animation to the pushed/popped viewController's view's layer:
This pushed/popped view controller's view is that one that had an UIActivityIndicatorView that wasn't animating properly.
Hope this helps!
只需将持续时间从 1.0 更改为 0.3 或更少
只是我经过测试并且它正在工作
just change your time duration from 1.0 to 0.3 or less
just i am tested and it's working