IOS---transform (control position, size, rotation change)

Source: Internet
Author: User

Knowledge Points: Control Transform properties

There are three ways to change the shape of a control

1,cgaffinetransformmaketranslation (PAN)

2,cgaffinetransformmakescale (contraction)

3,cgaffinetransformmakerotate (swivel)

First, actual combat

Create the project first, and add a uiimageview to the project, with three buttons translated, shrunk, rotated,

Add an output source for Uiimageview, three keys to add an output event

Here's where the real code implementation begins.

Cgaffinetransformmaketranslation Demo

TX is the x-coordinate of the control offset

Ty is the y-coordinate of the control offset

This demo is implemented to move the control down

int tx=self. Imageshow. Transform. TX;

int ty=self. Imageshow. Transform. Ty+1;

self. Imageshow. Transform=cgaffinetransformmaketranslation(TX, ty);

Cgaffinetransformmakescale Demo

Global variables

Float sx=1.0,sy=1.0

Cgaffinetransformmakescale inside the parameter Sx,sy value range 0-1, is the control scaling size, I define the global variable is to change the size of the control is defined.

sx+=0.1;xy+=0.1;

self. Imageshow. Transform=cgaffinetransformmakescale(SX, Sy);

Cgaffinetransformmakerotate Demo

Define global variables float angle=0;

Angele value range-1---0---1 is the angle of the control rotation

angle+=0.1;

self. Imageshow. Transform=cgaffinetransformmakerotation(Angel);

IOS---transform (control position, size, rotation change)

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.