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