【发布时间】:2015-09-17 04:28:27
【问题描述】:
如标题所述,我想在 UIView 中使用 CG/CA 或什至 OpenGL(如有必要)为一些沿着正弦曲线从底部到顶部行进的气泡设置动画。
这是我的 CA 代码 sn-p 工作正常,但它是一条动画直线。如何构建正弦曲线行为?
- (void)animateBubble:(UIImageView *)imgView {
[UIView beginAnimations:[NSString stringWithFormat:@"%i",imgView.tag] context:nil];
[UIView setAnimationDuration:6];
[UIView setAnimationDelegate:self];
imgView.frame = CGRectMake(imgView.frame.origin.x, 0, imgView.frame.size.width, imgView.frame.size.height);
[UIView commitAnimations];
}
我已经用 SpriteKit 实现了想要的结果(看看:http://youtu.be/Gnj3UAD3gQI)。气泡沿着正弦曲线从底部移动到顶部,其中幅度在随机范围内。此外,我使用陀螺仪传感器来额外影响路径。
这种行为是否可以通过 UIKit、CG、CA 以某种方式重现(如果绝对需要,也可以使用 OpenGL)?代码示例会很棒,但也非常感谢任何其他想法。
【问题讨论】:
标签: ios objective-c uiview core-graphics core-animation