简体   繁体   中英

CATextLayer foregroundColor animation don't work on iOS9 but work on iOS10 or high

CATextLayer foregroundColor animation don't work on iOS9 but work normal on iOS10 or high version! I don't know what's wrong with my code!

Code as follow:

- (void)addAnimationOnLayer:(CATextLayer*)layer{
CABasicAnimation *colorAn = [CABasicAnimation animationWithKeyPath:@"foregroundColor"];

colorAn.fromValue = (id)NeColor333333.CGColor;
colorAn.toValue = (id)NeColor999999.CGColor;


CABasicAnimation *sizeAn = [CABasicAnimation animationWithKeyPath:@"fontSize"];
sizeAn.fromValue = @16.0;
sizeAn.toValue = @12.0;


CAKeyframeAnimation *keyAn = [CAKeyframeAnimation animationWithKeyPath:@"position"];
keyAn.values = @[[NSValue valueWithCGPoint:layer.position],[NSValue valueWithCGPoint:CGPointMake(layer.position.x, layer.position.y - 16)]];
keyAn.keyTimes =@[@0.0,@1.0];

CAAnimationGroup *group = [CAAnimationGroup animation];
group.animations = @[colorAn, keyAn, sizeAn];
group.duration = 0.4;
group.repeatCount = 1;
group.fillMode = kCAFillModeForwards;
group.removedOnCompletion = NO;

[layer addAnimation:group forKey:nil];
}

您可以添加一个CALayer,并将CALayer蒙版设置为CATextLayer,您可以使用动画更改CALayer backgroundColor。

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