我试图在旋转 UIView 的同时滑动它。最终结果基本上是一个 UIView,它在屏幕上向左旋转约 70 度,碰到边缘,向右旋转约 50 度,最后静止(在几次摆动之后)。我能够让它滑动和旋转,但是当我尝试为第二次旋转设置动画时(一旦它碰到边缘),框架会回到原始值(回到屏幕左侧)。一旦 UIView 滑过,如何让框架粘住?
[UIView animateWithDuration:.4 delay:0.0
options:UIViewAnimationCurveEaseInOut
animations:^{
CGAffineTransform slideAndRotate = CGAffineTransformMakeTranslation(300, 0);
slideAndRotate = CGAffineTransformRotate(slideAndRotate, RADIANS(75));
self.ticketImageView.transform = slideAndRotate;
} completion:^(BOOL finished) {
// set the frame to the location where it ended up
NSLog(@"%@", NSStringFromCGRect(self.ticketImageView.frame));
[UIView animateWithDuration:.35
delay:0.05
options:UIViewAnimationCurveEaseInOut
| UIViewAnimationOptionBeginFromCurrentState
animations:^{
CGAffineTransform rightAngle1 =
CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-45.0));
[[self ticketImageView] setTransform:rightAngle1];
} completion:^(BOOL finished) {
}];