OS 3.1.2가 적용된 iPhone의 UILabel에서 수행하려고하는 두 개의 애니메이션이 있습니다. 첫 번째는 앞뒤로 UILabel의 바위 : 직접 UILabel의의 계층이 애니메이션의두 개의 코어 애니메이션을 CAAnimationGroup로 그룹화하면 하나의 CABasicAnimation이 실행되지 않습니다.
NSValue *value = nil;
CABasicAnimation *animation = nil;
CATransform3D transform;
animation = [CABasicAnimation animationWithKeyPath:@"transform"];
transform = CATransform3DMakeScale(3.5f, 3.5f, 1.0f);
value = [NSValue valueWithCATransform3D:transform];
[animation setToValue:value];
transform = CATransform3DMakeScale(1.0f, 1.0f, 1.0f);
value = [NSValue valueWithCATransform3D:transform];
[animation setFromValue:value];
[animation setAutoreverses:YES];
[animation setDuration:30.0f];
[animation setRepeatCount:10000];
[animation setBeginTime:0.0f];
추가 중 하나의 기대 작품으로 : 그것은 더 큰이가되도록
CAKeyframeAnimation *rock;
rock = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];
[rock setBeginTime:0.0f];
[rock setDuration:5.0];
[rock setRepeatCount:10000];
NSMutableArray *values = [NSMutableArray array];
MovingMath *math = [[MovingMath alloc] init];
// Center start position
[values addObject:[math DegreesToNumber:0]];
// Turn right
[values addObject:[math DegreesToNumber:-10]];
// Turn left
[values addObject:[math DegreesToNumber:10]];
// Re-center
[values addObject:[math DegreesToNumber:0]];
// Set the values for the animation
[rock setValues:values];
[math release];
두 번째는 UILabel의를 확대합니다.
이CAAnimationGroup *theGroup = [CAAnimationGroup animation];
theGroup.duration = 5.0;
theGroup.repeatCount = 10000;
theGroup.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
theGroup.animations = [NSArray arrayWithObjects:[self rockAnimation], [self zoomAnimation], nil]; // you can add more
// Add the animation group to the layer
[[self layer] addAnimation:theGroup forKey:@"zoomAndRotate"];
그룹에 애니메이션을 추가하는 순서는 중요하지 않습니다 : 나는 애니메이션을 함께 그룹화하려고하면
그러나, 첫 번째 애니메이션이 작동하지 않습니다 "흔들". 위의 방식으로 확대/축소 대신 테두리를 변경해 보았지만 실패했습니다. 어떤 통찰력이라도 대단히 감사하겠습니다. 고맙습니다.
아래 내 의견을 참고하십시오 ... 나는이 애니메이션이 동시에 발생하도록하고 싶습니다. 문제는 그룹을 사용할 때 rockAnimation이 실행되지 않는다는 것입니다. zoomAnimation 만 실행됩니다. – Christian