gpt4 book ai didi

ios - CATextLayer foregroundColor 动画不适用于 iOS9,但适用于 iOS10 或更高版本

转载 作者:行者123 更新时间:2023-11-28 23:42:37 27 4
gpt4 key购买 nike

CATextLayer foregroundColor 动画在 iOS9 上不起作用,但在 iOS10 或高版本上正常工作!我不知道我的代码有什么问题!

代码如下:

- (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 mask是一个CATextLayer,你可以用动画改变CALayer backgroundColor。

关于ios - CATextLayer foregroundColor 动画不适用于 iOS9,但适用于 iOS10 或更高版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53113749/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com