iOS Animation Programming-Advanced

Source: Internet
Author: User
Tags uikit

0. Animation Basics

    • Main animation Properties

1, XY coordinate properties: Position (the upper left corner is the origin)

2, Transparency properties: Opacity (transparent: 0.0, Opaque: 1.0)

3. Zoom Properties: Scale (Resize the object, such as the display of the dialog box)

4. Other properties: Color (colour property), Rotate (rotation property), 3D properties (such as 3D rollover)

    • Think about how the animation is formed

      1. Properties of the object at the beginning of the animation

      2. Properties of the object at the end of the animation

      3. Time of animation execution

      4. What happens during animation execution

      5. What happens after the animation is over

    • Animation curve

      1. Linear constant Change (Linear)

      2. Start at a slow speed: accelerated change (Ease in)

      3, first acceleration after the change of deceleration (Ease in,ease out)

      4. End at slow speed: deceleration change (Ease out)


1, Uikit and core Animation

    • Architecture

UIKit (IOS) and AppKit (OS X)

Core Animation

OpenGL ES and OpenGL Core Graphics

Graphics Hardware

    • Instance

// Create

Let RedBall = UIView(frame: cgrectmake( c8>, ())

RedBall. BackgroundColor = Uicolor . Redcolor ()

RedBall. Layer . Cornerradius = -

self. View . Addsubview (RedBall)

// Ball Zoom Animation

UIView. animatewithduration (0.5, delay: 0, options: uiviewanimationoptions. Curveeaseinout, animations: {(), Void in

RedBall. Transform = Cgaffinetransformmakescale (2, 2)

}) {(Finished:Bool) , Void in

Print("finished")

}

override func viewdidload () {

Super. Viewdidload ()

// Create

let redball = UIView(frame: cgrectmake( , ())

RedBall. BackgroundColor = Uicolor . Redcolor ()

RedBall. Layer . Cornerradius = -

self. View . Addsubview (RedBall)

// Ball Zoom Animation

UIView. animatewithduration (0.5, delay: 0, options: uiviewanimationoptions . Curveeaseinout, animations: {(), Void in

Redball.transform = Cgaffinetransformmakescale (2, 2)

// Combo animation , Cgaffinetransformconcat

RedBall. Transform = Cgaffinetransformconcat (cgaffinetransformmakescale(2.0, 2.0), cgaffinetransformmaketranslation (50))

}) {(Finished:Bool) , Void in

Print("finished")

}

}

Combo Animation:Cgaffinetransformconcat


override func viewdidload () {

Super. Viewdidload ()

// Create

let redball = UIView(frame: cgrectmake( , ())

RedBall. BackgroundColor = Uicolor . Redcolor ()

RedBall. Layer . Cornerradius = -

self. View . Addsubview (RedBall)

// Ball Zoom Animation

UIView. animatewithduration (0.5, delay: 0, options: uiviewanimationoptions. Curveeaseinout, animations: {(), Void in

Redball.transform = Cgaffinetransformmakescale (2, 2)

// Combo animation , Cgaffinetransformconcat

RedBall. Transform = Cgaffinetransformconcat (cgaffinetransformmakescale(2.0, 2.0), Cgaffinetransformmaketranslation(a )

RedBall. BackgroundColor = Uicolor . Greencolor ()

}) {(Finished:Bool) , Void in

Print("finished")

}

}

Elastic animation (Spring Animation),IOS 7.0 later have this animation

// Create

Let RedBall = UIView(frame: cgrectmake(5 0 , ())

RedBall. BackgroundColor = Uicolor . Redcolor ()

RedBall. Layer . Cornerradius = -

self. View . Addsubview (RedBall)

// elastic animations,IOS 7.0 later have this animation

UIView. animatewithduration (2.0, delay: 0, usingspringwithdamping: 0.3 ,// elastic damping, the value range is 0-1, the closer to 0, the more elastic effect of animation; if set to 1, the animation will not have an elastic effect

initialspringvelocity: 0 , // The speed at which the view starts at the beginning of the animation, usually should be passed in 0

Options: uiviewanimationoptions . Curveeaseinout, animations: {(), Void in

RedBall. Transform = Cgaffinetransformconcat (

cgaffinetransformmakescale(2, 2 ),cgaffinetransformmaketranslation(a )

)

RedBall. BackgroundColor = Uicolor . Greencolor ()

}) {(Finished:Bool) , Void in

Print("finished")

}


2, Jnwspringanimation

3. Facebook Pop (Facebook Paper)

iOS Animation Programming-Advanced

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.