IOS animation Entry 1: iOS animation entry

Source: Internet
Author: User

IOS animation Entry 1: iOS animation entry
1. animation Introduction

In iOS, the Animation implementation technology is Core Animation. Core Animation is responsible for all scrolling, rotating, downgrading and enlarging, and all iOS Animation effects. Among them, the UIKit class usually has the animated: parameter section, which allows whether to use animation.

This article describes how to implement the UIView animation, including basic methods and block methods.

Method 2: basic animation

[UIView beginAnimations: nil context: nil]; // animation start // Code... [UIView commitAnimations]; // animation end

// For example, set lb to move down [UIView beginAnimations: nil context: nil]; [UIView setAnimationDuration: 3]; CGPoint point = self. lb. center; point. y ++ = 100; self. lb. center = point; [UIView commitAnimations];

2 blcok method 1

[UIView animateWithDuration: 3 // animation duration animations: ^ {// Code...}];

// Eg change lb transparency [UIView animateWithDuration: 3 animations: ^ {self. lb. alpha = 0.5;}];

3 blcok method 2

UIView animateWithDuration: 3 // animation duration animations: ^ {// animation execution} completion: ^ (BOOL finished) {// animation execution after completion}];

// Example: CGAffineTransform endAngel = rotate (90.0f * (M_PI/180.0f); [UIView animateWithDuration: 3 animations: ^ {self. lb. transform = endAngel;} completion: ^ (BOOL finished) {self. stateLb. text = @ "animation completed" ;}];


4 blcok method 3

[UIView animateWithDuration: 3 // animation duration delay: 1 // animation latency options: UIViewAnimationOptionCurveEaseIn // set animation transition effect animations: ^ {// animation execution} completion: ^ (BOOL finished) {// execute after the animation is completed}];

// Eg change the lb font size and position [UIView animateWithDuration: 3 delay: 1 options: UIViewAnimationOptionCurveEaseInOut // set the animation transition effect animations: ^ {CGPoint center = self. lb. center; center. x = 200; self. lb. center = center; self. lb. textColor = [UIColor blueColor];} completion: ^ (BOOL finished) {self. stateLb. text = @ "modifying the font size and position of lb completed *" ;}];



5 blcok Method 4

[UIView animateWithDuration: 3 // animation duration delay: 1 // animation latency usingSpringWithDamping: 1.0 // set initialSpringVelocity: 5.0 for effects similar to spring effects // set the initial speed options: UIViewAnimationOptionCurveLinear // sets the animation transition effect animations: ^ {} completion: ^ (BOOL finished) {}];

[UIView animateWithDuration: 3 delay: 1 usingSpringWithDamping: 1.0 initialSpringVelocity: 5.0 options: UIViewAnimationOptionCurveEaseInOut animations: ^ {CGPoint center = self. btn. center; center. y + = 50; self. btn. center = center;} completion: ^ (BOOL finished) {self. stateLb. text = @ "Spring Effect ended" ;}];



Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.