[英]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
}];
還有其他動畫選項,如FromLeft
, FromTop
, FromBottom
使用任何一個到您的要求
看一下這個關於使用CATransform3D在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
}];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.