简体   繁体   中英

CABasicAnimation will not animate my opacity

I am using CABasicAnimation to try and animate my root level views layer and it won't animate. The animation is happening in about 0.2 NOT the 77.0 I have below.

CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
animation.beginTime = 1.0;
animation.duration = 77.0;
animation.fromValue = [NSNumber numberWithFloat:0.0f];
animation.toValue = [NSNumber numberWithFloat:1.0f];
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeBoth;
animation.additive = NO;

[self.layer addAnimation:animation forKey:@"show-anim" ];

您需要相对于当前媒体时间设置开始时间:

    animation.beginTime = CACurrentMediaTime() + 1;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM