检查UIView当前是否为动画

时间:2012-03-11 13:03:15

标签: ios cocoa-touch core-animation

我有两个动画正在运行;显示搜索栏和显示横幅。这两个动画都在调整相同视图的大小,如果它们在同一时间运行(它们是哪个),则最新动画将取消调整大小。无论如何都要检查UIView当前是否正在制作动画然后待机以进行动画制作?

我很确定我没有使用CAAnimations,因为Cocoa没有检测到这样的类。

此广告在收到广告时正在投放。不幸的是,这与ShowSearch运行的时间相同。

- (void)adViewDidReceiveAd:(GADBannerView *)bannerView {
    if (!hasloaded) {
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
        [UIView setAnimationDuration: 1.0];

        [bannerView_ setFrame:CGRectMake(0, self.view.frame.size.height, bannerView_.frame.size.width, bannerView_.frame.size.height)];

        // move and grow
        [bannerView_ setFrame:CGRectMake(0, self.view.frame.size.height-50, bannerView_.frame.size.width, bannerView_.frame.size.height)];
        // set original position
        [UIT setFrame:CGRectMake(UIT.frame.origin.x, UIT.frame.origin.y, UIT.frame.size.width, UIT.frame.size.height)];

        // move and grow
        [UIT setFrame:CGRectMake(UIT.frame.origin.x, UIT.frame.origin.y, UIT.frame.size.width, UIT.frame.size.height-50)];

        [UIView commitAnimations];
        hasloaded = true;
    }
}

2 个答案:

答案 0 :(得分:2)

您可以使用UIView方法+animateWithDuration:animations:completion:中的完成块(这是beginAnimations / commitAnimations的更现代的替代方法)来链接多个动画(我是猜猜这就是你想要做的事情吗?)。

答案 1 :(得分:0)

如果您在输入代码时选择代码并按 control + K ,您将保留格式并使其漂亮。试试吧。阅读将粘贴代码的文本墙转换为真实类型的非彩色格式环境。

Nick Weaver says:

  

UIView有一个图层(CALayer)。您可以向其发送animationKeys,它将为您提供一系列键,用于标识附加到图层的动画。我想如果有任何条目,动画正在运行。如果你想深入挖掘一下,看看CALayer采用的CAMediaTiming协议。它提供了有关当前动画的更多信息。

相关问题