동시에 두 개의 애니메이션을 실행하려고합니다. 하나는 하나의 uimageview에서 다른 것으로 전환하고 다른 하나는 레이블의 translation.x 애니메이션입니다. 레이블은 uiimageview 위에 있습니다.동시에 여러보기에서 여러 CAAnimations
하지만 번역이 제대로 작동하고 전환이 즉시 발생하거나 숨겨진 속성을 기반으로 전환이 발생합니다. 또한 내 레이블 만 이동해야합니다 (또한 숨김 상태에서도 볼 수 있음). 다른보기에 적용되기 때문에 나는 caanimationgroup을 사용할 수 없습니다.
...
CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.x"];
NSArray *xValues = @[[NSNumber numberWithFloat:myLabel.bounds.origin.x],
[NSNumber numberWithFloat:myLabel.bounds.origin.x + screenHalf],
[NSNumber numberWithFloat:myLabel.bounds.origin.x + screenHalf * 4]];
[anim setValues:xValues];
NSMutableArray *timeFrames = [NSMutableArray array];
CGFloat timeStep = 1.0/([xValues count] - 1);
for (NSInteger i = 0; i < [xValues count]; i++)
{
[timeFrames addObject:[NSNumber numberWithFloat:timeStep * i]];
}
[anim setKeyTimes:timeFrames];
[anim setDuration:duration];
[anim setFillMode:kCAFillModeForwards];
[anim setRemovedOnCompletion:FALSE];
[myLabel.layer addAnimation:anim forKey:nil];
...
//으로의 전이있는 UIImageView에서에 라벨을 슬라이딩
// CAKeyFrameAnimation 다른
...
CATransition *transition = [CATransition animation];
[transition setDuration:duration];
[transition setType:kCATransitionFade];
//These two are uiimageviews i'm switching from and to
initial.hidden = TRUE;
next.hidden = FALSE;
//Initial and next are subviews of container which itself is a subview of viewcontroller's main view
[container.layer addAnimation:transition forKey:@""];
내가 제대로 화면에 걸쳐 전환이 즉시 발생하는 이상과 같은 애니메이션과 라벨 슬라이드를 호출하는 경우 . 마지막 줄을 다음과 같이 변경하면 :
[self.view.layer addAnimation:transition forKey:@""];
숨겨진 애니메이션은 myLabel에도 적용됩니다. 위와 같은 애니메이션을 결합하기위한 수정은 무엇이며, 무엇이 더 정교하게 원인입니까?
는 여전히 대답을해야합니까 : 같을 것이다 CAKeyFrameAnimation 이것을 사용
사이비 코드? – kelin