我正在尝试执行一个同时执行三件事的动画:平移、旋转和更改图像的大小。
我可以一次做两个,翻译和大小。但是,当我在以下代码末尾添加旋转时,它会被忽略。如果我将它放在代码的开头,则忽略大小变化。我读过您可以使用 view.transform 进行复合转换,但是,我无法让它工作。
这是我当前的代码:
CGPoint destPoint = CGPointMake(-100,-50);
float radians =[self Degrees2Radians:-35];
[UIView animateWithDuration:2
animations:^{
//TRANSLATE
self.imageView.center = CGPointMake(self.imageView.center.x + destPoint.x, self.imageView.center.y + destPoint.y);
//ROTATE
self.imageView.transform = CGAffineTransformMakeRotation(radians);
//SCALE
self.imageView.transform = CGAffineTransformMakeScale(0.2, 0.2); // here the final size will be 20%
}
completion:nil
];
}
任何人都可以推荐让所有三件事同时发生的方法。
这是一些使用视图的转换属性的 swift 代码,但我无法在 Objective-C 中找到等效的代码。
view.transform= CGAffineTransform(scaleX: 1.5, y: 1.5)
view.transform = view.transform.rotated(by angle: CGFloat(45 * M_PI / 180))
在此先感谢您的任何建议。