Uibezierpath curve Animation for iOS development

Source: Internet
Author: User

Func Animation1 (layerparam:cashapelayer) {let        animation = cabasicanimation (keypath: "Strokestart")        Animation.fromvalue = 0        animation.tovalue = 1        animation.duration = 2.0        layerparam.addanimation (animation , Forkey: "")    }

This code can be used to achieve the drawing of the curve animation, Fromvalue and Tovalue respectively represents the animation starting point and the endpoint, 0 for the startpoint,1 represents endpoint, the entire path can be regarded as the unit 1,0.5 and other intermediate values are also possible. Don't forget to add the function

Self.animation1 (layer)

Ignore that mouse ...

It can also be written in the middle to both sides of the effect

Func Animation2 (layerparam:cashapelayer) {        Layerparam.strokestart = 0.5        layerparam.strokeend = 0.5                Let Animation1 = Cabasicanimation (keypath: "Strokestart")        animation1.fromvalue = 0.5        animation1.tovalue = 0        Animation1.duration = 2 let                animation2 = cabasicanimation (keypath: "Strokeend")        Animation2.fromvalue = 0.5        animation2.tovalue = 1        animation2.duration = 2                layerparam.addanimation (Animation1, Forkey: "")        Layerparam.addanimation (Animation2, Forkey: "")            }

The following effect can be obtained with linewidth

Func Animation3 (layerparam:cashapelayer) {let        animation = cabasicanimation (keypath: "LineWidth")        Animation.fromvalue = 1        animation.tovalue =        animation.duration = 2        layerparam.addanimation ( Animation, Forkey: "")    }

Round rectangles can be implemented in any of these.

Uibezierpath curve Animation for iOS development

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.