IOS realizes 3D floating effect animation _ios

Source: Internet
Author: User

The technical points involved

  1. Catransform3drotate
  2. Transformation coordinate system

Hierarchy of the overall view

  1. Tvoscardview
  2. Cardimageview
  3. Cardparallaxview

Code to transform a coordinate system

CGFloat xfactor = MIN (1, MAX ( -1, (Touchpoint.x-(SELF.BOUNDS.SIZE.WIDTH/2))/(SELF.BOUNDS.SIZE.WIDTH/2));
CGFloat yfactor = MIN (1, MAX ( -1, (Touchpoint.y-(SELF.BOUNDS.SIZE.HEIGHT/2))/(SELF.BOUNDS.SIZE.HEIGHT/2));

CardImageView.layer.transform = [Self transformwithm34:1.0/ -500 xf:xfactor yf:yfactor];
CardParallaxView.layer.transform = [Self transformwithm34:1.0/ -250 xf:xfactor yf:yfactor];

CGFloat zfactor = 180 * ATAN (yfactor/xfactor)/M_pi + 90;

Tvoscardanimation Animation's Running results

Wen/joycezhao (author of Jane book)
Original link: http://www.jianshu.com/p/42770b5cee0d
Copyright belongs to the author, reproduced please contact the author to obtain authorization, and labeled "Jane book author."

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.