OC, oc Language

Source: Internet
Author: User

OC, oc Language
Overview

  • Introduction

    • CAAnimationGroup is also called a group animation or animation group.
    • Place multiple animations in an animation group and assign them to the animation attributes of the layer. All animations in the animation group are concurrently executed.
  • Notes

    • The animation in the animation Group will not be compressed, and the part beyond the animation duration will be cut off
    • The delegate and removedOnCompletion attributes of the animation in the animation group will be ignored.
    • The removedOnCompletion attribute is ignored, and the animation end layer is restored to the State before the animation.
Unique attributes of CAAnimationGroup
  • Animations (NSArray *)

    • Stores all concurrently executed animations
    • The array element is a subclass of CAAnimation.
Example
  • Implementation

    • Create an animation group object group
    • Create multiple CABasicAnimation objects, which have different functions and failed attributes.
    • Assign multiple basic animation objects to the group's animations attribute.
    • Add an animation group to the layer where the animation is to be executed
    • Use implicit animation to change the background color of a Layer
  • Steps

    • Create a UIView control on the storyboard and have it. Modify its class attribute to a subclass of the custom UIView.
    @property (weak, nonatomic) IBOutlet UIView *redView;
    • Create an animation Group
    // Create an animation group Object CAAnimationGroup * group = [CAAnimationGroup animation]; // set the animation group execution time group. duration = 1.0; // create a basic animation object for scaling CABasicAnimation * scale = [CABasicAnimation animation]; scale. keyPath = @ "transform. scale "; scale. fromValue =@1.0; scale. toValue = @ 0.5; // create a basic animation object to rotate CABasicAnimation * rotation = [CABasicAnimation animation]; rotation. keyPath = @ "transform. rotation "; rotation. toValue = @ (arc4random_uniform (M_PI * 2); // creates a basic animation object to modify the position CABasicAnimation * position = [CABasicAnimation animation]; position. keyPath = @ "position"; position. toValue = [NSValue valueWithCGPoint: CGPointMake (arc4random_uniform (200) + 20, arc4random_uniform (200) + 20)]; // Add the basic animation to the animation group. animations = @ [scale, rotation, position];
    • Add an animation group to the layer where the animation is to be executed
    [self.redView.layer addAnimation:group forKey:nil];
    • Use implicit animation to change the background color of a layer
    self.redView.layer.backgroundColor = [self randomColor].CGColor;
    • Returns a random color.
    // Return random color-(UIColor *) randomColor {return [UIColor colorWithRed: arc4random_uniform (255)/255.0 green: arc4random_uniform (255)/255.0 blue: arc4random_uniform (255) /255.0 alpha: 1.0];}

     

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.