2013-06-26 2 views
1

다음 코드로 인해 레이블의 배경색이 변경되지 않는 이유가 확실하지 않습니다. 레이블의 레이어가 애니메이션에서 배경색을 바꿀 수 없는지 생각하고 있습니다. 누군가를 바라보며 나에게 답을 줄 수 있습니다. 고마워요!uilabel.layer.backgroundcolor가 CAKeyframeAnimation에서 작동하지 않습니다.

CAKeyframeAnimation *animation = [CAKeyframeAnimation animation]; 

    animation.values = [NSArray arrayWithObjects: 
         (id) [UIColor yellowColor].CGColor, 
         (id) [UIColor redColor].CGColor, 
         (id) [UIColor blueColor].CGColor, nil]; 

    animation.duration = 3.0f; 
    animation.autoreverses = NO; 

    [updateRecordLabel.layer addAnimation:animation forKey:@"backgroundColor"]; 

답변

1

애니메이션의 keyPath를 설정하지 않았습니다. 난 당신이 오해 생각

1. CAKeyframeAnimation *theAnimation=[CAKeyframeAnimation animationWithKeyPath:@"backgroundColor"]; 

2.CAKeyframeAnimation *theAnimation = [CAKeyframeAnimation animation]; 
    [theAnimation setKeyPath:@"backgroundColor"]; 

'애니메이션 forKey : addAnimation을 "의 backgroundColor"] @'당신은 애니메이션을 만들 수 있습니다 forkey, 키는 애니메이션의 '이름'이지만, 속성이 아니라 키 패스는 것 생기있다.