我想滑动UIView同时也旋转它。最终的结果基本上是一个UIView,它在屏幕上向左旋转约70度,碰到边缘,向右旋转约50度,最后结束静止(在几次摆动之后)。我可以让它滑动和旋转,但是当我尝试对第二个旋转进行动画处理时(一旦它碰到边缘),框架会回到原始值(回到屏幕的左侧)。一旦UIView滑过,我该如何获取框架?幻灯片和旋转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) {
}];
感谢您的精彩提示!使用中心肯定比翻译坐标容易得多!这个算法效果很好。 – Clay 2012-07-19 02:21:03