繁体   English   中英

UIImageview旋转动画

[英]UIImageview rotation animation

我想将动画应用于两个UIImageViews 想法是图像1水平翻转90度,然后图像2翻转完成旋转。 可以把它想象成一个硬币旋转:头侧(图像1)朝前 - >转90度 - >尾侧(图像2)旋转朝前。 我可以做动画的前半部分,但我被困在第二部分。

[UIView animateWithDuration:1.0f animations:^{
    image1.transform = CGAffineTransformMakeScale(-0.01, 1);
} completion: ^(BOOL finished) {
    // How can I make image 2 to rotate out as if it initially was already rotated by 90 degrees?
}];

对于翻转动画,有一个名为UIViewAnimationOptionTransitionFlipFromRight的动画选项,例如使用UIView's动画方法,如下例所示

 [UIView transitionWithView:myImageView //with first image
                  duration:animationDuration
                   options:UIViewAnimationOptionTransitionFlipFromRight
                animations:^{
                    myImageView.image = toImage; //to next image
                } completion:^(BOOL finished) {
             //completion actions after flipped
 }];

还有其他动画选项,如FromLeftFromTopFromBottom使用任何一个到您的要求

看一下这个关于使用CATransform3D在3D中翻转UIView的问题。

简单的核心动画UIView的3D变换

答案:

CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -1000.0;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, M_PI * 0.6, 1.0f, 0.0f, 0.0f);
[UIView animateWithDuration:1.0 animations:^{
    self.someView.layer.anchorPoint = CGPointMake(0.5, 0);
    self.someView.layer.transform = rotationAndPerspectiveTransform;
} completion:^(BOOL finished){
    // code to be executed when flip is completed
}];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM