X-Axis scaling:
Cabasicanimation *theanimation;
Theanimation=[cabasicanimation animationwithkeypath:@ "transform.scale.x"];
theanimation.duration=8;
Theanimation.removedoncompletion = YES;
Theanimation.fromvalue = [NSNumber numberwithfloat:1];
Theanimation.tovalue = [NSNumber numberwithfloat:0.5];
[Yourview.layer addanimation:theanimation forkey:@ "Animatetransform"];
Y-Axis scaling:
Cabasicanimation *theanimation;
Theanimation=[cabasicanimation animationwithkeypath:@ "Transform.scale.y"];
theanimation.duration=8;
Theanimation.removedoncompletion = YES;
Theanimation.fromvalue = [NSNumber numberwithfloat:1];
Theanimation.tovalue = [NSNumber numberwithfloat:0.5];
[Yourview.layer addanimation:theanimation forkey:@ "Animatetransform"];
X-axis, with the y-axis scaled at the same time:
Cabasicanimation *theanimation;
Theanimation=[cabasicanimation animationwithkeypath:@ "Transform.scale"];
theanimation.duration=8;
Theanimation.removedoncompletion = YES;
Theanimation.fromvalue = [NSNumber numberwithfloat:1];
Theanimation.tovalue = [NSNumber numberwithfloat:0.5];
[Yourview.layer addanimation:theanimation forkey:@ "Animatetransform"];
The above scaling is centered on the center point of the view, and if you need to customize the zoom point, you can set the point:
Center Point
[Yourview.layer setanchorpoint:cgpointmake (0.5, 0.5)];
Upper left corner
[Yourview.layer setanchorpoint:cgpointmake (0, 0)];
Lower right corner
[Yourview.layer setanchorpoint:cgpointmake (1, 1)];
IOS Layer Animations