가 나는 CALayer
의 배경 색상을 애니메이션이 코드를 사용하려고 시도하고있어 작동하지 않습니다코어 애니메이션 - 애니메이션
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"backgroundColor"];
animation.duration = 0.3;
animation.fromValue = (id)[backgroundLayer backgroundColor];
animation.toValue = (id)[[UIColor redColor] CGColor];
[backgroundLayer addAnimation:animation forKey:@"animateBackgroundColor"];
을 어떤 이유로,이 아무것도하지 않습니다.
[backgroundLayer setBackgroundColor:[[UIColor redColor] CGColor]];
작품을 (비록 애니메이션없이) 사용 : 간단하게 사용
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"opacity"];
animation.duration=0.3;
animation.fromValue = [NSNumber numberWithFloat:1.0];
animation.toValue = [NSNumber numberWithFloat:0.0];
[backgroundLayer addAnimation:animation forKey:@"animateOpacity"];
작품을 너무 (애니메이션).
왜 배경색을 애니메이트 할 수 없습니까?
편집 : 문제는 내 backgroundColor
이 (단색을 사용하여 작동합니다 ... UIImage
의 구현을 사용) 패턴 이미지로 생성된다는 사실과 관련이 있습니다. 나는 아직도이 문제에 대한 해답을 찾고있다.