【问题标题】:Animating subviews to spin image to full screen动画子视图以将图像旋转到全屏
【发布时间】:2011-08-01 15:25:55
【问题描述】:

我有一个 UIImageView (100x100px),当用户点击图像时,我想做一个动画,使图像全屏显示。

动画是将帧更改为全屏和旋转图像的 CABasicAnimation 的组合。

我是这样设置的:

[self.view bringSubviewToFront:imageView];

CGRect originalFrame = CGRectMake(20.0, 20.0, 100.0, 100.0);
CGRect fullFrame = CGRectMake(0.0, 0.0, 320.0, 320.0);

CGRect newFrame = (isImageFullScreen ? originalFrame : fullFrame);

CABasicAnimation* spinAnimation = [CABasicAnimation
                                   animationWithKeyPath:@"transform.rotation.y"];
spinAnimation.duration = 0.5;
spinAnimation.toValue = [NSNumber numberWithFloat:2*M_PI];

[imageView.layer addAnimation:spinAnimation forKey:@"spinAnimation"];


[UIView animateWithDuration:0.6
                      delay:0.25 
                    options:UIViewAnimationOptionTransitionNone
                 animations:^{
                                imageView.frame = newFrame;
                                button.frame = newFrame;
                             } 
                 completion:nil];

问题在于旋转动画。 在我看来,当图像旋转时,还有一些其他的子视图会保持在顶部。

我怎样才能使这个工作,使图像在我的其他子视图之上动画?

【问题讨论】:

    标签: ios animation subview


    【解决方案1】:

    找到解决方案。

    添加: imageView.layer.zPosition = imageView.layer.bounds.size.width;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-15
      • 1970-01-01
      相关资源
      最近更新 更多