- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试创建一个非常简单的关键帧动画,其中图形通过给定的中点从一个角度旋转到另一个角度。
(目的是能够通过大于 180 度的
OBTUSE
弧角来制作旋转动画,而不是让动画“作弊”并走最短路线,即通过相反的路线
, ACUTE
较小的角度——当只有一个[即目的地]关键帧时可能会发生这种情况。为了走得更远,我假设我需要一个额外的关键帧,沿着所需的弧线。)
这是我到目前为止所得到的(它确实通过最锐角使图形达到所需的旋转):
#define DEGREES_TO_RADIANS(__ANGLE__) ((__ANGLE__) / 180.0 * M_PI)
...
[UIView beginAnimations:nil context:nil];
CGAffineTransform cgCTM = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(desiredEndingAngle));
[UIView setAnimationDuration:0.5];
graphic.transform = cgCTM;
[UIView commitAnimations];
据我了解,我并不是在寻找沿着路径的动画(因为那是为了平移,而不是旋转)......
无论如何,我们将非常感谢任何帮助!提前致谢。
最佳答案
我想我已经明白了。
以下代码(在本示例中)执行完整 270 度旋转(1.5*pi 弧度),包括可以进一步自定义的各种参数:
CALayer *layer = rotatingImage.layer;
CAKeyframeAnimation *animation;
animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.duration = 0.5f;
animation.cumulative = YES;
animation.repeatCount = 1;
animation.values = [NSArray arrayWithObjects: // i.e., Rotation values for the 3 keyframes, in RADIANS
[NSNumber numberWithFloat:0.0 * M_PI],
[NSNumber numberWithFloat:0.75 * M_PI],
[NSNumber numberWithFloat:1.5 * M_PI], nil];
animation.keyTimes = [NSArray arrayWithObjects: // Relative timing values for the 3 keyframes
[NSNumber numberWithFloat:0],
[NSNumber numberWithFloat:.5],
[NSNumber numberWithFloat:1.0], nil];
animation.timingFunctions = [NSArray arrayWithObjects:
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn], // from keyframe 1 to keyframe 2
[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut], nil]; // from keyframe 2 to keyframe 3
animation.removedOnCompletion = NO;
animation.fillMode = kCAFillModeForwards;
[layer addAnimation:animation forKey:nil];
谢谢!
关于iphone - 基本关键帧动画(旋转),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1031177/
是否有一个 FFMPEG 命令,如果我们传递一个视频文件,在每个场景更改时它都应该为它生成一个关键帧。我理解的关键帧是视频的一系列文件(图像或视频)文件,可用于在视频悬停时播放。请让我们知道我们是否可
我正在切换我通过带有 JQuery 的 toggleClass 触发的一系列动画/过渡。 其中一个动画正在使用以下内容: .header { transition: all .3s ease-
我有一些图片可以在关键帧中很好地滚动 @-webkit-keyframes headImage /* Safari and Chrome */ { 0% {background:url(../imag
尝试用 jQuery 制作一个简单的重复关键帧动画 $(document).ready(function() { $('body').mouseover(function() {
我在 richard bradshaw 找到了一个关于 css3 transitions 的很好的教程,可以在 http://css3.bradshawenterprises.com/cfimg/ 我
我正在尝试使用@keyframes 为背景交换设置动画。背景是径向渐变。背景发生变化,但不是动画。 #mydiv { background: radial-gradient(circle at 90%
如果单击按钮 2,您将看到动画运行。但是,当我使用另一个功能对按钮进行更改(选中复选框以显示。隐藏按钮)时,动画会再次运行,就像再次按下一样。 如何防止每次单独的函数对按钮进行更改时触发动画?即在切换
所以我创建了图像生成器(生成 RGB 的非常简单的一个)我希望能够将一定数量的图像转换为 H264 关键帧+相关帧(lats 说 100)所以在生成的每 100 帧上我需要将它们编码为 H264 .怎
我一直在尝试自学一些带有关键帧的 css 动画,我正在尝试创建一些东西,其中有一个小方 block 落下,然后从那个方 block 中,一个矩形从左边突出,然后显示一些大约 8 秒后发短信,然后 re
我意识到我不能简单地通过用逗号分隔@keyframes mymove、@-moz-keyframes mymove 等来完成下面相同的代码。。为了让它们工作,我需要如下分别声明它们。 有什么方法可以将
恐怕有类似的问题,但我没有找到具体的解决方案,所以我创建了一个 fiddle : http://jsfiddle.net/Garavani/yrnjaf69/2/ TEXT
我有一个包含多个坐标的图像映射。但是,当我在上面放置一个关键帧 div (clouds) 时,这个不起作用,因为动画覆盖了 map 。最后一个 div 是一个动画,有一些云从图像上掠过。 html代码
所以我正在尝试为元素创建 Wifi 闪烁效果。首先圆圈应该是可见的,然后是上面的圆圈,依此类推。在所有符号都可见后,它应该等待 2 秒,然后重新开始。你可以在这里看到我的当前状态: http://js
我试图在单击按钮时显示一条消息。我想要“GO!”淡入/淡出表示游戏开始,但只有在单击开始按钮时才会出现。我现在正在尝试使用 jquery 和另一个来自老师的库的 javascript,它结合了鼠标点击
我正在尝试使用以下代码让对象在背景中从左向右浮动。不幸的是,当它离开屏幕时,尽管向类添加了 overflow-y: hidden 属性,但仍会出现垂直滚动条。我尝试了百分比(100% 与过渡)但它没有
我正在为将鼠标悬停在图形图像上时的弹跳效果创建关键帧。我的一切都正常工作,但是一旦动画完成..图标就会消失。 我知道它与电子邮件中设置的 translateY 属性有关,并在类里面链接。 在悬停时,我
你好我正在尝试模拟翻转倒数计时器但是当我编写代码时我发现两者之间存在差异: @keyframes zindex { 0% { z-index: 2; } 5% { z-index: 4
如果我有: @keyframes animateleft{from{left:-300px;opacity:0} to{left:0;opacity:1}} 是否可以: @keyframes anim
我有一个弹出窗口,它在单击按钮时打开,然后在您单击另一个按钮或弹出窗口之外时关闭。我希望弹出窗口在打开时淡入并在关闭时淡出。如何使用 javascript 在两个关键帧之间切换? 我尝试通过使用 ja
我正在尝试使用 jquery Keyframes用于动态创建的关键帧动画。我的页面上有六个图标(可能更多),它们都需要设置为以下范围内的随机 x 和 y 值的动画: x = 1-5y = 13-20
我是一名优秀的程序员,十分优秀!