0
두 개의 UIView에 y 축을 중심으로 CATransform3DRotate를 적용하면 z 순서가 바뀐 것 같습니다. z 축으로 다시 회전 된 UIView의 섹션은 화면을 향해 회전 한 섹션 앞에 나타납니다.올바른 z- 순서를 얻는 방법 CATransform3D
가 어떻게이 예상대로 Z-주문의 동작하므로받을 수 있나요 :이 애니메이션은 무슨 뜻인지 보여줍니다?
는 내가 그 애니메이션을 생성하는 데 사용되는 코드는 다음과 같습니다 (이중 [UIView animateWithDuration]
단지에 제대로 전체 회전에 필요) : 당신의 변환에
@interface ViewController()
@property (strong, nonatomic) UIView *blueSquare;
@property (strong, nonatomic) UIView *redSquare;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.blueSquare = [[UIView alloc] initWithFrame:(CGRect){.origin = {160,234}, .size = {400,300}}];
self.blueSquare.backgroundColor = [UIColor blueColor];
[self.view addSubview:self.blueSquare];
self.redSquare = [[UIView alloc] initWithFrame:(CGRect){.origin = {464,234}, .size = {400,300}}];
self.redSquare.backgroundColor = [UIColor redColor];
[self.view addSubview:self.redSquare];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[UIView animateWithDuration:5 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0/900.0; // for perspective
transform = CATransform3DRotate(transform, M_PI, 0, 1, 0);
self.blueSquare.layer.transform = transform;
self.redSquare.layer.transform = transform;
} completion:^(BOOL finished) {
[UIView animateWithDuration:5 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
CATransform3D transform = CATransform3DIdentity;
transform.m34 = 1.0/900.0; // for perspective
transform = CATransform3DRotate(transform, 2*M_PI-0.001, 0, 1, 0);
self.blueSquare.layer.transform = transform;
self.redSquare.layer.transform = transform;
} completion:nil];
}];
}
@end
변환의 원근감은 변경되지 않습니다. 그것을 음수 값으로 변경하십시오. –
@ DavidRönnqvist 그게 다야, 고마워! 나는 내가 간단한 것을 놓친다는 것을 알았다. 이것을 자신의 대답으로 넣으면 나는 그것을 받아 들인 것으로 표시 할 것입니다. – Jayson