延时动画方法

来源:互联网 发布:免费广告录音软件 编辑:程序博客网 时间:2024/05/16 06:12

-(void)buttonClick

{

   [selfdelay:0complete:^{

       [UIViewtransitionWithView:self.demoViewduration:1.5options:UIViewAnimationOptionTransitionFlipFromBottomanimations:^{

           [self.viewaddSubview:self.demoView];

       } completion:^(BOOL finished) {     

       }];

   }];

    [selfdelay:1complete:^{

        [UIViewtransitionWithView:self.demoView1duration:1.5options:UIViewAnimationOptionTransitionFlipFromBottomanimations:^{

            [self.viewaddSubview:self.demoView1];

        } completion:^(BOOL finished) { 

        }];        

    }];

}


-(void)delay:(double)second complete:(void(^)(void))animate

{

    NSTimeInterval delay =dispatch_time(DISPATCH_TIME_NOW, (int64_t)(second *NSEC_PER_SEC));

    dispatch_after(delay,dispatch_get_main_queue(), ^{

        animate();

    });

}

0 0