iOS Development transform

Source: Internet
Author: User

Transform mainly used in animation

1 , let a button move up each time - the distance

UIButton *head = (UIButton *) [Self.view viewwithtag:10];

Head.transform = cgaffinetransformtranslate (head.transform, 0,-100);

Transform is a state that cannot change the real position of the control (in the starting position as a reference, starting at (0,0), that is, the real position is (0,0)), if using cgaffinetransformmaketranslation (0,- 100) It returns the state of the control moving up 100 pixels up in the real position, but the real position does not change, and when the second execution head.transform = cgaffinetransformmaketranslation (0,-100) No more changes, Because the control is already in this state.

2 , make the button rotate

UIButton *head = (UIButton *) [Self.view viewwithtag:10];

M_pi_4 is the PI angle of 4 points--45°

Angle is positive: clockwise, angle is negative: counterclockwise

Head.transform = Cgaffinetransformrotate (Head.transform, m_pi_4);

When rotated, its starting x and Y coordinates are rotated as well. Also cannot use Head.transform = Cgaffinetransformmakerotation (-m_pi_4) for the same reason

3 , make button zoom

UIButton *head = (UIButton *) [Self.view viewwithtag:10];

Head.transform = Cgaffinetransformscale (head.transform, 1.5, 1.5);

Also cannot use Head.transform = Cgaffinetransformmakescale (1.5, 1.5) for the same reason

iOS Development transform

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.