【问题标题】:iPad : CATransform3DMakeRotation flipping issue: half of the view is not visibleiPad:CATransform3DMakeRotation 翻转问题:一半的视图不可见
【发布时间】:2011-04-14 16:04:57
【问题描述】:

我编写了一些代码来将图像视图旋转 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];



                                                               }];
                                              }];

                     }];

【问题讨论】:

  • 请编辑您的帖子并重新粘贴代码 - 使用 {} 按钮对其进行格式化。
  • tempView.frame = CGRectMake(0 + 5, 0 +5, propertyView.frame.size.height-10, propertyView.frame.size.width-10); tempView.center = propertyView.center;在这里你正在改变框架。请在动画前后打印您的 imageView 对象,看看两者之间有什么区别。

标签: iphone transitions


【解决方案1】:

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

myView.layer.zPosition = 1000.0;

【讨论】:

  • 你刚刚用这个答案结束了我 3 小时的痛苦。谢谢!
  • 你不知道自己有多厉害!
  • 我不知道为什么-1000.0(负值)对我有用
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-10-26
  • 2012-11-11
  • 1970-01-01
相关资源
最近更新 更多