Possible Duplicate:
How to use CGAffineTransformMakeRotation?
我有一个像按钮一样的 ImageView ,我正在寻找一种方法来向用户显示他点击了它,我想出了这个代码来稍微旋转它:
float angle = 60.0;
[UIView animateWithDuration:0.5f animations:^{
customimageView.transform = CGAffineTransformMakeRotation(angle);
}];
但它没有做我正在寻找的行为。 有人知道如何让图像在点击时放大(或放大/放大)到 1.5 倍吗?什么样的动画与这里相关? 请随意分享你们认为在这种情况下很酷的行为。
谢谢。
顺便说一句,我怎样才能让它旋转一整圈?我尝试传入 360 但它不这样做?
最佳答案
您始终可以通过使用 CGAffineTransformMakeScale 进行的缩放变换来 CGAffineTransformConcat 旋转。
如果您对另一个按钮按下效果感兴趣,我也需要一些很酷的东西,并选择了“颤动”动画,如下所示:
BOOL keepThrobbing = NO;
-(void)buttonThrob:(CGFloat)inset {
UIViewAnimationOptions opts = UIViewAnimationOptionBeginFromCurrentState|UIViewAnimationOptionAllowUserInteraction;
[UIView animateWithDuration:0.2 delay:0.0 options:opts animations:^{
self.button.frame = CGRectInset(self.button.frame, inset, inset);
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.2 delay:0.0 options:opts animations:^{
self.button.frame = CGRectInset(self.button.frame, -inset, -inset);
} completion:^(BOOL finished) {
if (finished && keepThrobbing) {
[self buttonThrob:inset];
}
}];
}];
}
这样调用它:
keepThrobbing = YES;
[self buttonThrob:10.0]; // expand/shrink by 10px in x and y
关于ios - 点击imageview的动画,酷炫的小放大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13963896/