【发布时间】:2011-07-05 21:24:42
【问题描述】:
给定:
[UIView beginAnimations:nil context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[UIView setAnimationDuration:.5];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:card cache:NO];
myPic = [UIImage UIImagenamed: @"mySecondImage.png"];
[UIView commitAnimations];[/CODE]
通过翻转从右到左为“myPic”设置动画。
我需要获得相同的动画,但要垂直。从顶部翻转或从底部翻转。我环顾四周,没有人真正推荐过工作模型。
我试过了,但是没有运气:
float duration = .5;
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
animation.fromValue = [NSNumber numberWithDouble:0.0f * M_PI];
animation.toValue = [NSNumber numberWithDouble:1.0f * M_PI];
animation.duration = duration;
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeBoth;
animation.repeatCount =1;;
animation.beginTime = CACurrentMediaTime();
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
card.layer.anchorPoint = CGPointMake(0.5, 1.0);
[card.layer addAnimation:animation forKey:@"rotationX"];[/CODE]
任何输入? 提前致谢。
【问题讨论】:
-
您应该编辑这个问题,为您的代码使用“代码”布局,使其真正可读。
-
很抱歉。刚刚改了。
-
定义“不走运”。运行这段代码会发生什么?
-
在那 0.5 秒内,您看到图像向上移动,然后突然倒置。