OC, oc Language

Source: Internet
Author: User

OC, oc Language
Overview

  • Introduction

    • Core animation provides a very powerful set of animation APIs, which can efficiently achieve most brilliant animation effects.
  • Notes

    • Core animation operations are executed in child threads without blocking the main thread
    • The core animation works directly with CALayer objects, not UIView objects.
  • Differences between core animation and UIView Animation

    • The core animation does not change the frame attribute of the control, but only displays an illusion.
    • The UIView animation changes the frame attribute of the control, and displays the real frame attribute of the control.
Core Animation
  • Relationship Diagram of core animation classes

    • This figure is from the official document. I do not know why CAKeyframeAnimation in the lower right corner is a protocol. Subclass that uses CAKeyframeAnimation as CAPropertyAnimation
  • CAAnimation and CAPropertyAnimation

    • They are both abstract classes and cannot be used directly. They must be subclasses.
    • Subclass that can be directly used by CAAnimation,

      • CAAnimationGroup, Group Animation
      • CATransaction, transfer Animation
    • Subclass that can be directly used by CAPropertyAnimation

      • CABasicAnimation, basic animation
      • CAKeyframeAnimation, Key Frame Animation
CAAnimation class
  • Three important attributes

    • TimingFunction (CAMediaTimingFunction *), speed control function
    • Delegate (id), animation proxy
    • RemovedOnCompletion (BOOL), whether to remove the animation from the layer after execution
Proxy method of CAAnimation
  • Note:

    • The proxy method of CAAnimation is implemented by NSObject classification,

  • Proxy Method

    • Call at animation start
    - (void)animationDidStart:(CAAnimation *)anim;
    • Call when animation ends
    - (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag;
CAMediaTiming Protocol
  • Common attributesMedium attribute

    • BeginTime (CFTimeInterval), start time
    • Duration (CFTimeInterval), the execution time of a single Animation
    • Speed (float), animation speed
    • TimeOffset (CFTimeInterval): starts from the time offset timeOffset to execute the animation, compresses the animation before timeOffset, and concatenates it to the end.
    • RepeatCount (float), repeatCount
    • RepeatDuration (CFTimeInterval), animation repetition time, And repeatCount select the shortest time
    • Autoreverses (BOOL), whether to restore to the animation starting state (in Animation Mode)
    • FillMode (NSString *): animation filling mode
Animation filling mode
  • Note:

    • To make the fill mode valid, set the removedOnCompletion attribute of the animation to NO.
  • Four modes

    • KCAFillModeForwards: After the animation ends, the layer remains in the animation end state.
    • KCAFillModeBackwards: add the animation to the layer and immediately enter the initial state of the animation. Wait until the animation starts to run.
    • KCAFillModeBoth
    • KCAFillModeRemoved. After the animation ends, the layer will return to its original state.
Animation Speed Control Function
  • KCAMediaTimingFunctionLinear, constant speed
  • KCAMediaTimingFunctionEaseIn
  • KCAMediaTimingFunctionEaseOut, entering at full speed, slowing down to the target location
  • KCAMediaTimingFunctionEaseInEaseOut
  • KCAMediaTimingFunctionDefault, default speed, that is, kCAMediaTimingFunctionEaseInEaseOut

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.