GCD延迟实现的动画 效果

本文详细介绍了如何通过改进动画实现方式,使用GCD延迟调用自身来解决动画效果问题,实现了流畅的循环动画效果。通过调整关键参数和动画属性,展示了从启动到完成的完整动画过程,并通过示例代码演示了具体实现步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

通过自身调自身这种方法实现的动画经常出各种问题,现在改用GCD延迟下调自身这种方法:

/**

 *  动画效果

 */

//- (void)circularCharingAnimation

//{

//    NSLog(@"--------------------------------------");

//    if (self.circularStopFlag) return;

//    [UIView animateWithDuration:2.0 animations:^{

//

//        self.circularImageView.alpha = 0.0;

//        self.circularImageView.frame = CGRectMake(0, 0, 260.0, 260.0);

//        self.circularImageView.center = self.cycleView.center;

//        

//    } completion:^(BOOL finished) {

//        self.circularImageView.alpha = 1.0;

//        self.circularImageView.frame = CGRectMake(0, 0, 184.0, 184.0);

//        self.circularImageView.center = self.cycleView.center;

//        [self circularCharingAnimation];

//    }];

//}




- (void)circularCharingAnimation

{

    if (self.circularStopFlag) return;

    

    [UIView animateWithDuration:2.0 animations:^{

        

        self.circularImageView.alpha = 0.0;

        self.circularImageView.frame = CGRectMake(0, 0, 260.0, 260.0);

        self.circularImageView.center = self.cycleView.center;

        

    }];

    

    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC));

    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){

        

        self.circularImageView.alpha = 1.0;

        self.circularImageView.frame = CGRectMake(0, 0, 184.0, 184.0);

        self.circularImageView.center = self.cycleView.center;

        

        [self circularCharingAnimation];

    });


}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值