Reflection of iOS Animation

Source: Internet
Author: User

Reflection of iOS Animation
1. Result Display

2. Implementation ideas

1. Use the copy layer to create a UIImageView to display the image, and then copy the UIImageView.

Note:The copy layer can only copy child layers, but the UIImageView has only one main layer and has no child layers. Therefore, you cannot directly copy the UIImageView.

2. correct practice: add the UIImageView to a UIView, and copy the UIView layer to copy the UIImageView.

Note:By default, control A is A child control of control B. The layer of control A is the child layer of control B.

3. If there is a problem, the default UIView layer is not the copy layer. We want to change the UIView layer to the copy layer and rewrite the + layerClass method.

+ (Class)layerClass{    return [CAReplicatorLayer class];}

4. reflection effect: rotate the copied image to 180 degrees and then pan down. It is best to offset the image first and rotate it.

CAReplicatorLayer * layer = (CAReplicatorLayer *) self. v. layer; layer. instanceCount = 2; // The first Y axis offset CATransform3D transform = CATransform3DMakeTranslation (0, self. v. bounds. size. height, 0); // rotate transform = CATransform3DRotate (transform, M_PI, 1, 0, 0); // set the deformation layer of the replication layer. instanceTransform = transform; // sets the color channel offset, which is equal to the offset of the previous point, that is, the shadow effect layer. instanceRedOffset =-0.1; layer. instanceGreenOffset =-0.1; layer. instanceBlueOffset =-0.1; layer. instanceAlphaOffset =-0.1;
3. Demo implementation

 

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.