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.