- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在开发一个带有一些简单动画的 iPhone 应用程序。
我有一个想要翻译的 View ,但不是沿着一条线。我想用抛物线的方式翻译它。想象一下,我正在制作一辆沿着弯曲道路行驶的汽车的动画。
我知道我可以将变换正确设置为 CGAffineTransform 的实例
问题是,我不知道如何创建转换。我知道如何缩放、平移等,但如何进行抛物线平移?这可能吗?
最佳答案
要沿着平滑曲线制作动画,您需要使用 CAKeyframeAnimation。在 this answer我提供了组合动画的代码,该动画沿曲线移动 ImageView ,同时调整其大小并使其淡出。该代码的相关部分如下:
// Set up path movement
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeForwards;
pathAnimation.removedOnCompletion = NO;
CGPoint endPoint = CGPointMake(480.0f - 30.0f, 40.0f);
CGMutablePathRef curvedPath = CGPathCreateMutable();
CGPathMoveToPoint(curvedPath, NULL, viewOrigin.x, viewOrigin.y);
CGPathAddCurveToPoint(curvedPath, NULL, endPoint.x, viewOrigin.y, endPoint.x, viewOrigin.y, endPoint.x, endPoint.y);
pathAnimation.path = curvedPath;
CGPathRelease(curvedPath);
这将创建一条具有两个控制点的曲线,一个位于 View 的原点,另一个位于显示屏的右上角(横向模式)。有关构建路径的更多信息,请参阅 Quartz 2D Programming Guide或Animation Types and Timing Programming Guide .
要使用此动画,您需要使用如下所示的内容将其添加到 View 的图层中:
[imageViewForAnimation.layer addAnimation:pathAnimation forKey:@"curveAnimation"];
关于iphone - 如何进行抛物线转换?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1886158/
我需要让 Excel 将大约 5 个点绘制成一条曲线。如果这些点没有完美排列,我正在寻找的是所有点的平均值。我对 Excel 上的绘图不是很熟悉,所以很可能我忽略了一些选项来获得我想要实现的目标。 这
我想做类似this的事情,但要相反-以便摄像机在外面并指向内部。让我们从抽象开始,并进行具体说明: 1)是否有任何工具可以帮我做到这一点?我可以使用现有软件多近的距离? 2)说最近的工具是像OpenC
我使用 JFreeChart 写了一个简单的抛物线图。 package parabolademo; import java.awt.geom.Point2D; import java.awt.geom
我得到了三个点,需要绘制一条平滑的 3D 抛物线。问题是曲线起伏不定,而且有一些奇怪的凹痕 这是我的代码... func drawJump(jump: Jump){ let halfDista
我目前正在开发一款2D Android 游戏, 在这个游戏中,一个ViewObject(Bitmap)在Parabola Path上在屏幕上移动,就像在这个图像中一样,但是这个路径是静态的,静态路径正
我是一名优秀的程序员,十分优秀!