CATransform3D uses

struct CATransform3D

{

CGFloat m11 (x-axis scaling), m12 (y-axis shearing), m13, m14 (x-axis stretching);

CGFloat m21 (x-axis shear), m22 (y-axis shrink), m23, m24 (y-axis stretch);

CGFloat m31, m32, m33, m34;

CGFloat m41 (x-axis translation), m42 (y-axis translation), m43 (z-axis translation), m44 (zoom in);

};

Example:

Comparison chart

UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];

img.image = [UIImage imageNamed:@"11"];

[self.view addSubview:img];

Modify the figure

UIImageView *caimg = [[UIImageView alloc]initWithFrame:CGRectMake(100, 200, 100, 100)];

caimg.image = [UIImage imageNamed:@"11"];

[self.view addSubview:caimg];

1. Parallel movement

CATransform3DMakeTranslation(tx,ty,tz)

tx: move in the x-axis direction, right move is a positive number

ty: move in the y-axis direction, and move down is a positive number

tz: move in the z-axis direction, the outward move is a positive number

CATransform3D translation = CATransform3DMakeTranslation(0.0, 80.0, 5.0);

caimg.layer.transform = translation;

2. Zoom

CATransform3DMakeScale(CGFloat sx, CGFloat sy, CGFloat sz)

sx: zoom in the x-axis direction, greater than 1 zoom. less than 1 zoom out

sy: scale in the y-axis direction, greater than 1 to zoom in. less than 1 zoom out

sz: zoom in the z-axis direction, greater than 1 zoom. less than 1 zoom out

CATransform3D scale = CATransform3DMakeScale(2, 2, 5);

  caimg.layer.transform = scale;

3. Rotation

CATransform3DMakeRotation (CGFloat angle, CGFloat x,CGFloat y, CGFloat z)

angle: rotation angle

x: rotate around the x-axis, the value range is -1 to 1

y: rotate around the y-axis, the value range is -1 to 1

z: rotate around the z axis, the value range is -1~1

CATransform3D rotation = CATransform3DMakeRotation(M_PI/3, 1, 1, 1); caimg.layer.transform = rotation;

4. Compound row

CATransform3DIsIdentity (CATransform3D t)

t: CATransform3D type, can be attached

CATransform3DTranslate (CATransform3D t, CGFloat tx,

CGFloat ty, CGFloat tz)

CATransform3DScale (CATransform3D t, CGFloat sx,

CGFloat sy, CGFloat sz)

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325162110&siteId=291194637