iOS UIlabel 的字體 字體顏色加入動畫一開始考慮的是核心動畫可惜并不支持,
最發(fā)現(xiàn)了 CATextLayer 可以完成 但是 和UIlbel 是有很多差別的 需要渲染等屬性支撐 才能和label 一樣 代碼如下:
CATextLayer * text = [CATextLayer layer];
text.frame = CGRectMake(100, 100, 300, 100);
text.string = @"asdasd";
[self.view.layer addSublayer:text];
CABasicAnimation *anima = [CABasicAnimation animationWithKeyPath:@"foregroundColor"];
anima.fromValue = (id) [UIColor redColor].CGColor;
anima.toValue = (id) [UIColor greenColor].CGColor;
anima.repeatCount = 1;
anima.removedOnCompletion = NO;
anima.fillMode = kCAFillModeForwards;
anima.duration = 5;
[text addAnimation:anima forKey:@"foregroundColor"];