Swift UIView Brief animation

Source: Internet
Author: User

Swift UIView comes with some simple animations.

If this is not a complex requirement, consider using the method here.

Let's try it a little bit.

First create three views to set the three-in-one background color

        Let View1=uiview (Frame:cgrectmake (Ten, A, $)) Let        View2=uiview (Frame:cgrectmake ()        View3=uiview (Frame:cgrectmake, Max, max))        View1.backgroundcolor=uicolor.redcolor ()        View2.backgroundcolor=uicolor.greencolor ()        View3.backgroundcolor=uicolor.bluecolor (        ) Self.view.addSubview (View1)        Self.view.addSubview (view2)        Self.view.addSubview (VIEW3)

Down we add an animation to View1, let him delay 1 seconds to execute, and eventually enlarge his size to 300.300, the position is unchanged. Colors fade into Blue

            Uiview.animatewithduration (2,            delay:1, Options:UIViewAnimationOptions.CurveEaseInOut, animations: {() Void in                View1.frame=cgrectmake (ten, +)                View1.backgroundcolor=uicolor.bluecolor ()                        }) {( Finished), Void in                        }

You can see the effect when you run it.


We see a closure on the top finished not used

We can try to use

            Uiview.animatewithduration (2, delay:1, Options:UIViewAnimationOptions.CurveEaseInOut, animations: {(), Void in View1.frame=cgrectmake (ten, +, +) VIEW1.BACKGROUNDCOLOR=UICOLOR.BL                    Uecolor ()}) {(finished), Void in Uiview.animatewithduration (2, Delay:1, Options:UIViewAnimationOptions.CurveEaseInOut, animations: {(), Void in view1.fr                                            Ame=cgrectmake (Ten, A, View1.backgroundcolor=uicolor.redcolor) ()                            }) {(finished), Void in Uiview.animatewithduration (2,                                Delay:1, Options:UIViewAnimationOptions.CurveEaseInOut, animations: {(), Void in                                View1.frame=cgrectmake (Ten, View1.backgroundcolor=uicolor.bluecolor) ()                            }) {(finished), Void in} }        }

OK, run to see the effect.

Simple effect to say, you can continue to try new features, there are problems can be added group discussion

Apple Development Group: 414319235 Welcome to join the Welcome discussion question

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Swift UIView Brief animation

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.