내 개체에 두 개의 UIImageViews가 있고 책처럼 페이지를 움직이기 위해 노력하고 있습니다. 나는 내장 애니메이션의 일부를 잠시 사용했고 (UIViewAnimationTransitionFlipFromLeft/Right
), 나는 더 잘할 수있을 것이라고 결정했다.CABasicAnimation의 가시성 (겹침) 문제 CALayer 변환
내 애니메이션을 작동시키기 위해 거기에서 추정 해낼 수있었습니다 ...하지만 문제는 내가 움직이는 이미지 (오른쪽 이미지)입니다.)은 항상 왼쪽 이미지 아래에 을 표시합니다.
다음은 초기화 코드이다 :
// set up some rects for use later
landscapeLeftRect = CGRectMake(0, 12, 512, 725);
landscapeRightRect = CGRectMake(512, 12, 512, 725);
// all our images
imageLeft = [[UIImageView alloc] initWithFrame:portraitRect];
imageRight = [[UIImageView alloc] initWithFrame:landscapeRightRect];
... 실제 애니메이션을 수행하는 (이 애니메이션의 두 번째 절반, 절반이므로주의를 나의 imageLeft보기 "중복") :
내가 해봤// set the image to be nextLeft
//[imageRight setImage:image.nextLeft];
[self.view sendSubviewToBack:imageLeft];
[self.view bringSubviewToFront:imageRight];
//[imageRight.layer setZPosition:1.0f];
[imageRight setFrame:landscapeLeftRect];
// remove any previous animations
[imageRight.layer removeAllAnimations];
// set up the anchorPoint and center
if (imageRight.layer.anchorPoint.x != 1.0f) {
imageRight.layer.anchorPoint = CGPointMake(1.0f, 0.5f);
imageRight.center = CGPointMake(imageRight.center.x + imageRight.bounds.size.width/2.0f, imageRight.center.y);
}
// create an animation to hold the first half of the page turning forward
CABasicAnimation *transformAnimation = [CABasicAnimation animationWithKeyPath:@"transform"];
transformAnimation.removedOnCompletion = YES;
transformAnimation.duration = 0.40f;
transformAnimation.delegate = self;
transformAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
// start the animation from the current state
CATransform3D endTransform = CATransform3DMakeRotation(3.141f/2.0f,
0.0f,
-1.0f,
0.0f);
// these values control the 3D projection outlook
endTransform.m34 = -0.001f;
endTransform.m14 = 0.0015f;
transformAnimation.fromValue = [NSValue valueWithCATransform3D:endTransform];
// we should end up at the beginning...
transformAnimation.toValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
[imageRight.layer addAnimation:transformAnimation forKey:nil];
것들 : (위의 코드에서 모두 볼 수 있습니다)
- bringSubviewToFront/sendSubviewToBac 어떤 조언이나 지혜를 사전에 레이어에
감사를 A ~ Z 인덱스를 설정
2 년이 지난 지금이 질문을 보는 사람은 누구나 페이지 뷰 컨트롤러 ('UIPageViewController')를 살펴보고 애니메이션을 사용해야합니다. – livingtech