我想制作一个UIView动画,以便其右侧变小然后再返回。点击此UIView中的UIButton时将触发此动画。这是我想要的一个快速模型-UIView将从状态1>状态2>状态1进入:
好像它被推向一侧。
这是我要执行的另一项操作的代码-这使UIView越来越小,就好像它被推向中心而不是侧面。
self.myView.transform = CGAffineTransformMakeScale(0.95,0.95);
self.myView.alpha = 1.f;
[UIView beginAnimations:@"button" context:nil];
[UIView setAnimationDuration:0.5];
self.myView.transform = CGAffineTransformMakeScale(1,1);
self.myView.alpha = 1.0f;
[UIView commitAnimations];
如何将相同的效果应用到右侧?任何帮助将不胜感激,谢谢!
最佳答案
根据这个question,例如,您不需要进行“透视变换”,就对我链接的问题进行了一些修改
CATransform3D perspectiveTransform = CATransform3DIdentity;
perspectiveTransform.m34 = 1.0 / -500;
perspectiveTransform = CATransform3DRotate(perspectiveTransform, 40.0f * M_PI / 180.0f, 0.0f, 1.0f, 0.0f);
[UIView animateWithDuration:0.4 animations:^{
self.myView.layer.transform = perspectiveTransform;
}];
编辑2回到原始
- (void)startAnimation:(id)sender
{
CATransform3D perspectiveTransform = CATransform3DIdentity;
perspectiveTransform.m34 = 1.0 / -500;
perspectiveTransform = CATransform3DRotate(perspectiveTransform, 40.0f * M_PI / 180.0f, 0.0f, 1.0f, 0.0f);
[UIView animateWithDuration:1.4 animations:^{
self.myView.layer.transform = perspectiveTransform;
}completion:^(BOOL finished) {
CATransform3D originalPerspectiveTransform = CATransform3DIdentity;
[UIView animateWithDuration:0.9 animations:^{
self.myView.layer.transform = originalPerspectiveTransform;
}];
}];
}
关于ios - 缩放/动画UIView的一侧变小? -CGAffineTransformMakeScale,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23748876/