Often see some good animation load view, idle to write a book page flip style animation load view, the core technology is calayer+coreanimation.
Here's the point:
To create a separate layer:
/* Create a Calayer object using the class method */
Calayer * layer = [calayer layer];
/* Catransform is actually a struct and therefore cannot directly assign values to the inner element */
Catransform3d transform = layer.transform;
/* Set the stereo effect value of layer M34 to render a stereo effect for this value */
TRANSFORM.M34 = 10.5/-2000;
Layer.transform = transform;
/* Set the background color of the layer, note the Cgcolor type */
Layer.backgroundcolor = [K_color_stock[_currentindex%k_color_stock.count] cgcolor];
/* Sets the anchor point, which is the center point of the animation, the default is (two-dimensional environment) (0.5.0.5), respectively, the x-axis midpoint of the y-axis */
Layer.anchorpoint = Cgpointmake (0, 0.5);
Layer.frame = CGRectMake (200, 100, 30, 45);
/* Set the center point of the layer to be familiar with center of the UIView object */
Layer.position = Cgpointmake (K_IOS_WIDTH/2, k_ios_height/2-50);
[Self.layer Addsublayer:layer];
Create a page-flipping animation
/* Create a page-flipping animation */
Cabasicanimation *basic = [cabasicanimation animationwithkeypath:@ "TRANSFORM.ROTATION.Y"];
/* TRANSFORM.ROTATION.Y Animation Start value */
Basic.fromvalue = @ (-M_PI);
/* TRANSFORM.ROTATION.Y Animation End value */
Basic.tovalue = @ (0);
/* Whether to automatically revert back to the original state after the animation has ended */
basic.autoreverses = NO;
/* Animation execution times */
Basic.repeatcount = 1;
/* Animation Duration */
Basic.duration = 1.0;
/* Animated Fill mode */
Basic.fillmode = kcafillmoderemoved;
/* Set Agent */
Basic.delegate = self;
[Layer addanimation:basic forkey:@ "BASC"];
When multiple layer animations are added in the previous method, and the interval is 0.2s, there will be a left-to-right page-flipping animation effect. If you want to be more perfect, you can add these layers to an array, and after the left-to-right animation is complete, add a reverse animation to the layer in the array to animate the page-back. As follows:
The core animation realizes the book page turn effect loading animation