//
// Mjviewcontroller. m
// 08-core animation 04-catransition
//
// Created by Apple on 14-4-21.
// Copyright (c) 2014 itcast. All rights reserved.
//
# Import "mjviewcontroller. H"
@ Interface mjviewcontroller ()
// Upload
-(Ibaction) Previous;
// Next
-(Ibaction) next;
@ Property (weak, nonatomic) iboutlet uiimageview * iconview;
/**
* Index of the current image
*/
@ Property (nonatomic, assign) int index;
@ End
@ Implementation mjviewcontroller
-(Ibaction) Previous {
Self. Index --;
If (self. Index =-1 ){
Self. Index = 8;
}
Nsstring * filename = [nsstring stringwithformat: @ "mongod.jpg", self. index + 1];
Self. iconview. Image = [uiimage imagenamed: Filename];
Catransition * anim = [catransition animation];
// Anim. type = @ "cube ";
// Anim. Subtype = kcatransitionfromleft;
Anim. type = @ "pageuncurl ";
Anim. duration= 0.5;
[Self. View. layer addanimation: anim forkey: Nil];
}
-(Ibaction) Next {
Self. Index ++;
If (self. Index = 9 ){
Self. Index = 0;
}
Nsstring * filename = [nsstring stringwithformat: @ "mongod.jpg", self. index + 1];
Self. iconview. Image = [uiimage imagenamed: Filename];
// Transfer Animation
Catransition * anim = [catransition animation];
Anim. type = @ "pagecurl ";
// Anim. type = kcatransition
// Anim. Subtype = kcatransitionfromright;
Anim. duration= 0.5;
// Animation start point
// Anim. startprogress = 0.0;
//
// Animation end point
// Anim. endprogress = 0.5;
[Self. View. layer addanimation: anim forkey: Nil];
}
@ End
Simple use of catransition