Ios 设置子视图动画以将图像旋转到全屏

Ios 设置子视图动画以将图像旋转到全屏,ios,animation,subview,Ios,Animation,Subview,我有一个UIImageView(100x100px),当用户点击图像时,我想制作一个动画,使图像全屏显示 动画是将帧更改为全屏和旋转图像的CABASICANIATION的组合 我是这样设置的: [self.view bringSubviewToFront:imageView]; CGRect originalFrame = CGRectMake(20.0, 20.0, 100.0, 100.0); CGRect fullFrame = CGRectMake(0.0, 0.0, 320.0, 3

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

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

我是这样设置的:

[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];
问题在于旋转动画。 在我的视图中,还有一些其他子视图在图像旋转时保持在顶部

我如何才能使这项工作,使图像在我的其他子视图上动画?

找到解决方案

增加: imageView.layer.zPosition=imageView.layer.bounds.size.width