Ios UIImageview旋转动画
我想将动画应用于两个Ios UIImageview旋转动画,ios,objective-c,animation,uiimageview,uiviewanimation,Ios,Objective C,Animation,Uiimageview,Uiviewanimation,我想将动画应用于两个uiimageview。这个想法是让图像一水平翻转90度,然后图像二完成旋转。把它想象成一枚硬币在旋转:头侧(图一)朝前->旋转90度->尾侧(图二)朝前旋转。我可以做动画的前半部分,但我被困在第二部分 [UIView animateWithDuration:1.0f animations:^{ image1.transform = CGAffineTransformMakeScale(-0.01, 1); } completion: ^(BOOL finished)
uiimageview
。这个想法是让图像一水平翻转90度,然后图像二完成旋转。把它想象成一枚硬币在旋转:头侧(图一)朝前->旋转90度->尾侧(图二)朝前旋转。我可以做动画的前半部分,但我被困在第二部分
[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的
动画方法一起使用,如下所示
[UIView transitionWithView:myImageView //with first image
duration:animationDuration
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^{
myImageView.image = toImage; //to next image
} completion:^(BOOL finished) {
//completion actions after flipped
}];
还有其他动画选项,如左起的
,
从顶部
,从底部
根据您的需要使用任意一个对于翻转动画,有一个名为UIViewAnimationOptionTransitionFlipFromRight
的动画选项,例如,与UIView的
动画方法一起使用,如下所示
[UIView transitionWithView:myImageView //with first image
duration:animationDuration
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^{
myImageView.image = toImage; //to next image
} completion:^(BOOL finished) {
//completion actions after flipped
}];
还有其他动画选项,如左起的
,
从顶部
,从底部
根据需要使用任意一个查看有关使用CATTransferM3D在3D中翻转UIView的问题
答案是:
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
}];
看看这个关于使用CATTransform3D在3D中翻转UIView的问题 答案是:
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
}];
尝试在第一个的完成块内添加另一个animateWithDuration块。尝试在第一个的完成块内添加另一个animateWithDuration块