检查 UIView 当前是否正在动画

Hed*_*dam 5 cocoa-touch core-animation ios

我有两个动画正在运行;显示搜索栏和显示横幅。这两个动画都在调整同一个视图的大小,如果它们同时运行(它们是),最新的动画将取消调整大小。无论如何要检查 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;
    }
}
Run Code Online (Sandbox Code Playgroud)

omz*_*omz 2

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