iOSanimationBezier /正弦曲线

我正在寻找在iOS中的循环animation单线贝塞尔曲线。 我头上的想法类似于Siri之前iPhone 4上的Voice Control屏幕。 曲线不需要对任何事情作出反应,即。 audio,麦克风等。只需要从左到右循环,并改变曲线的幅度。

我已经尝试了几个testing,这是最接近我来: IOS:animation变换从一条线到贝塞尔曲线

我需要知道如何animation实际的曲线,使其看起来好像在移动,而不是上下移动。

如果任何人有一些光芒,这将是真棒!

谢谢!

哇,我今天的工作完全一样。 :)检查这个:

所以我画我的波浪的观点被初始化为:

_self_view = [[TDTWaveView alloc] initWithFrame:CGRectMake(-320, 174, 640, 200)]; 

然后在我的viewDidLoad中,我打电话给[self animateWave]; 一旦。

 - (void)animateWave { [UIView animateWithDuration:.5 delay:0.0 options:UIViewAnimationOptionRepeat|UIViewAnimationOptionCurveLinear animations:^{ _self_view.transform = CGAffineTransformMakeTranslation(+_self_view.frame.size.width/2, 0); } completion:^(BOOL finished) { _self_view.transform = CGAffineTransformMakeTranslation(0, 0); }]; } 

这使波浪可能是你想要的一种线性运动。

就wave的代码而言,我将分享这个drawrect。

 self.yc = 30//The height of a crest. float w = 0;//starting x value. float y = rect.size.height; float width = rect.size.width; int cycles = 7;//number of waves self.x = width/cycles; CGContextRef context = UIGraphicsGetCurrentContext(); CGMutablePathRef path = CGPathCreateMutable(); CGContextSetLineWidth(context, .5); while (w <= width) { CGPathMoveToPoint(path, NULL, w,y/2); CGPathAddQuadCurveToPoint(path, NULL, w+self.x/4, y/2 - self.yc, w+self.x/2, y/2); CGPathAddQuadCurveToPoint(path, NULL, w+3*self.x/4, y/2 + self.yc, w+self.x, y/2); w+=self.x; } CGContextAddPath(context, path); CGContextDrawPath(context, kCGPathStroke);