Effect Demo
Baidu external selling Wave effect chart:
You need to know.
Cadisplaylink
In short, it's a timer that uses the same brush frame and screen frequency to redraw the rendering page.
How it is created:
Cadisplaylink *timer = [Cadisplaylink displaylinkwithtarget:self selector: @selector (Wave)];
[Timer Addtorunloop:[nsrunloop Currentrunloop] formode:nsrunloopcommonmodes];
Cashapelayer
CALayer
Subclass, which is usually combined CGPath
to draw the graph.
How it is created:
Cashapelayer *layer = [Cashapelayer Layer];
Layer.frame = self.bounds;
Layer.fillcolor = Self.realWaveColor.CGColor;
Layer ... and other attributes
[Self.view.layer Addsublayer:layer];
Its advantages
High rendering efficiency renders fast. With CAShapeLayer
hardware acceleration, it is much faster to draw the same graphic Core Graphics
.
Use memory efficiently. One CAShapeLayer
does not need to CALayer
create a boarding graph as usual, so no matter how large it is, it will not consume too much memory.
is not clipped by layer boundaries. One CAShapeLayer
can be drawn outside the bounds. Your layer path will not Core Graphics
be trimmed as usual in use. CALayer
No pixels will appear. When you CAShapeLayer
make a 3D transform, it doesn't become pixel like a normal layer with a boarding map.
Trigonometric function
Ideas to achieve
UIView --> 2个CAShapeLayer --> imageView.frame.orgin.y
Adjustment
Main code implementation
Final effect:
The above is the entire content of this article, I hope that the development of iOS can help you. If you have questions, you can leave a message for discussion.