objective-c - ios 关于animationDidStop动画完成后执行哪个动画的问题
PHPz
PHPz 2017-04-17 17:56:56
0
2
243
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    animation.fromValue = @(1.0);
    animation.toValue = @(1.5);
    animation.duration = 0.3f;
    animation.removedOnCompletion = NO;
    animation.fillMode = kCAFillModeForwards;
    animation.delegate = self;
    [_view1.layer addAnimation:animation forKey:@"animationPosition1"];
    
    
        -(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{
    NSLog(@"dfdfdfdf:%@",[_view1.layer valueForKey:@"animationPosition1"]); // 为什么这句是null
    if ([_view1.layer valueForKey:@"animationPosition1"] == anim) {
        NSLog(@"anim:%@",anim);
    }
    
}

我就想达到某一个动画结束做某件事 但是 NSLog(@"dfdfdfdf:%@",[_view1.layer valueForKey:@"animationPosition1"]);始终为空 求解答

PHPz
PHPz

学习是最好的投资!

membalas semua(2)
阿神
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
    animation.fromValue = @(1.0);
    animation.toValue = @(1.5);
    animation.duration = 0.3f;
    animation.removedOnCompletion = NO;
    animation.fillMode = kCAFillModeForwards;
    animation.delegate = self;
    [animation setValue:@"fi" forKey:@"presentKey"];
    [_view1.layer addAnimation:animation forKey:@"animationPosition1"];
    
    
        -(void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag{

    if ([anim valueForKey:@"presentKey"]) {
    //todo
    }
    
}
阿神


Atau gunakan pertimbangan rentetan [[_view1.layer animationKeys].firstObject isEqualToString:@"animationPosition1"];

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan