IOS to achieve the effect of Baidu external head wave _ios

Source: Internet
Author: User

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

CALayerSubclass, 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.yAdjustment

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.