I want to draw some bezier lines and I want to animate them with a wave effect,
Do you have some ideas about how I can do this ? Bezier line is it the best method to do it ? I found only 2 libs for this, but they are not really useful for what I need, I try to modify the code of one lib, unfortunately without success https://github.com/yourtion/YXWaveView
I found this lib, https://antiguab.github.io/bafluidview/ which does the work, but it written in obj-c, maybe you know something like this in swift
You can use a display link, a special kind of timer optimized for screen refresh rates, to change the
path
that is being rendered. The handler for the display link should calculate the amount of time that has elapsed and modify the path to be rendered accordingly. You can either use aCAShapeLayer
to render the path, or you can use a customUIView
subclass. The shape layer is probably easier:The only tricky part is writing a
wave
function that yields aUIBezierPath
for a particular time and yields the desired effect when you call it repeatedly as time passes. In this one, I'm rendering a sine curve, where the amplitude and the offset vary based upon the time that has elapsed at the point that the path is generated, but you can do whatever you want in your rendition. Hopefully this illustrates the basic idea.The above code yields: