iPad:CATransform3DMakeRotation翻转问题:视图的一半不可见

时间:2011-04-14 16:04:58

标签: iphone transitions

我编写了一些代码将图像视图旋转90度然后翻转它。然而翻转似乎切断了一半的图像。为什么会这样?

UIImageView *tempView = [[UIImageView alloc] initWithFrame:button.frame];
    tempView.image = [UIImage imageNamed:@"propertyCard.png"];
    //tempView.backgroundColor = [UIColor redColor];
    tempView.opaque = YES;
    [self.view addSubview:tempView];

    [UIView animateWithDuration: 1
                          delay: 0
                        options: UIViewAnimationOptionBeginFromCurrentState
                     animations:^{

                         // rotate
                         tempView.layer.transform = CATransform3DMakeRotation(M_PI /2, 0., 0, 1);                        
                     }
                     completion:^(BOOL finished) {

                         [self showPropertyViews];

                         [UIView animateWithDuration: 1 
                                               delay: 0
                                             options: UIViewAnimationOptionBeginFromCurrentState
                                          animations:^{

                                              // flip
                                              tempView.layer.transform = CATransform3DMakeRotation(M_PI, 1.0,1.0,0.0);

                                          }
                                          completion:^(BOOL finished) {


                                              [UIView animateWithDuration: 1
                                                                    delay: 0
                                                                  options: UIViewAnimationOptionBeginFromCurrentState
                                                               animations:^{

                                                                  tempView.frame = CGRectMake(propertyView.frame.origin.y + 12, propertyView.frame.origin.x +12, propertyView.frame.size.height-20, propertyView.frame.size.width-20);
                                                                  tempView.center = propertyView.center;
                                                               }
                                                               completion:^(BOOL finished) {

                                                                   tempView.hidden = YES;
                                                                   propertyView.hidden = NO;
                                                                   propertyView.alpha = 1;
                                                                   [self displayCoverFlow];

                                                                   [tempView removeFromSuperview];
                                                                   [tempView release];



                                                               }];
                                              }];

                     }];

1 个答案:

答案 0 :(得分:7)

当您的视图几乎垂直于屏幕时,视图层次结构中的某些其他视图将覆盖更远的一半。尝试为动画视图设置一些“足够大”的Z值,例如:

myView.layer.zPosition = 1000.0;