Core animation-transfer animation, core animation Transfer

Source: Internet
Author: User

Core animation-transfer animation, core animation Transfer

Transfer Animation: CATransition

Attribute introduction:

① Type: animation effect of transition Animation

KCATransitionFade cross fade transition

The new kCATransitionMoveIn view is moved to the old view.

KCATransitionPush New View releases old view

KCATransitionReveal removes the old view and displays the new view below.

Private api for animation effects of transition Animation

PageCurl page up

PageUnCurl flip down one page

RippleEffect dripping Effect

SuckEffect: the effect of contraction is extracted from a cloth.

Cube Effect

OglFlip flip up and down

② Subtype: Transition animation effect direction

KCATransitionFromRight

KCATransitionFromLeft

KCATransitionFromTop

KCATransitionFromBottom

③ StartProgress start progress (0, 1)

④ EndProgress end progress

The above is an introduction to transition animation.

The Code is as follows:

First, create a UIImageView in Main. storyBoard, set the image and contentModel, right-click and drag it to the Project @ interface.

# Import "ViewController. h "@ interface ViewController () {// int index of the image;} @ property (weak, nonatomic) IBOutlet UIImageView * imageView; @ end @ implementation ViewController-(void) viewDidLoad {[super viewDidLoad];}-(IBAction) leftSwipe :( id) sender {[self changImageWithDirection: YES];}-(IBAction) rightSwipe :( id) sender {[self changImageWithDirection: NO];}-(void) changImageWithDirection :( BOOL) directi On {CATransition * animation = [CATransition animation]; animation. duration = 2; if (direction! = YES) {index --; NSLog (@ "to the right"); animation. type = @ "oglFlip"; // The up/down flip effect is animation. subtype = kCATransitionFromLeft; // orientation to left} else {index ++; NSLog (@ ""); animation. type = @ "cube"; // cube effect animation. subtype = kCATransitionFromRight;} if (index <0) {index = 6;} if (index> 6) {index = 0;} self. imageView. image = [UIImage imageNamed: [NSString stringWithFormat: @ "community administrator d.jpg", index + 1]; [self. imageView. layer addAnimation: animation forKey: @ ""] ;}@ end

The effect is as follows:

 

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.