How to identify animations completed or not? [closed]

前提是你 提交于 2019-12-11 17:26:55

问题


I am trying to find out whether my animation runs and completed or else it is still in process??

animationImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320 , 480)];
animationImageView.animationImages = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"eg1"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg1"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg1"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"], nil];
animationImageView.animationDuration = 2.2f;
animationImageView.animationRepeatCount=1;
[self.view addSubview:animationImageView];
[animationImageView startAnimating];

Can anyone help me?

I am having UIview over a container which holds UITableviewcontroller, i given segue to my view controller from navigation controller. Now i would like to run my UIView with navigation bar hidden. I tried with code but it is in vain either both views having navigation bar or both does not have.

I am working with storyboard.

Actually am using UIImageView for "Splashscreen" purpose.


回答1:


try this

[UIView animateWithDuration:2.2f animations:^{

    UIImageView *animationImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320 , 480)];
    animationImageView.animationImages = [[NSArray alloc] initWithObjects:[UIImage imageNamed:@"eg1"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg1"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg1"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"],[UIImage imageNamed:@"eg2"], nil];
    animationImageView.animationDuration = 2.2f;
    animationImageView.animationRepeatCount=1;
    [self.view addSubview:animationImageView];
    [animationImageView startAnimating];

} completion:^(BOOL finished) {
    NSLog(@"Finished");
}];

To find out animating or not

    if ([YourAnimationImageView isAnimating]) {

        NSLog(@"Yes animation in progress");
    }
    else{
        NSLog(@"NO. animation has been stopped/finished");
    }


来源:https://stackoverflow.com/questions/23805962/how-to-identify-animations-completed-or-not

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!