Simple use of iOS basic Cgaffinetransform

Source: Internet
Author: User

The Cgaffinetransform class in the Coregraphics framework can be used to set the transform properties of the UIView, control the zoom, rotate, and pan operations of the view:

Also known as the radiation transformation matrix, can refer to linear algebra matrix implementation mode 0.0

The Cgaffinetransform official documentation is attached here:

Https://developer.apple.com/library/ios/documentation/GraphicsImaging/Reference/CGAffineTransform/index.html

Transform is a state, and there is only one state

(1) Cgaffinetransformmaketranslation (< #CGFloat Tx#>, < #CGFloat ty#>): Can only be changed once, because changes in this way are always changed with the most primitive state values, So it only changes once.

For example:

UIButton *head = (UIButton *) [Self.view viewwithtag:10];  Head.transform = Cgaffinetransformmaketranslation (0,-10);

(2) Cgaffinetransformtranslate (Cgaffinetransform T, < #CGFloat Tx#>, < #CGFloat ty#>): Able to change many times, Each change is a change in the state of the above (Cgaffinetransform T), so multiple changes can be made

  0,-ten);

(3) Cgaffinetransformidentity: Clears all settings of the transform (general and animated with use, can only be used for transfofrm settings of the screen)

    UIButton *head = (UIButton *) [Self.view Viewwithtag:ten];     = Cgaffinetransformidentity;

(4) Cgaffinetransformmakescale (cgfloat sx, cgfloat sy)(zoom: Set scale) The effect of the view rushing and indenting the frequency screen is achieved only by setting the zoom scale.

    UIButton *head = [Self.view viewwithtag:ten];     = Cgaffinetransformscale (head.transform,1.5,1.5);

(5)cgaffinetransformmakerotation (cgfloat angle)(rotation: Set rotation angle)

   UIButton *head =  [Self.view viewwithtag:ten];     = Cgaffinetransformmakerotation (m_pi_2);

    UIButton *head = (UIButton *) [Self.view Viewwithtag:ten];     = Cgaffinetransformrotate (Head.transform,-m_pi_4);

Simple use of iOS basic Cgaffinetransform

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.