【发布时间】: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];
问题在于旋转动画。 在我看来,当图像旋转时,还有一些其他的子视图会保持在顶部。
我怎样才能使这个工作,使图像在我的其他子视图之上动画?
【问题讨论】: