ios - 点击imageview的动画,酷炫的小放大

标签 ios xcode

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/

相关文章:

iphone - 裁剪录制的视频- objective-c

ios - 错误 : 'Unable to add mapping for keyPath news, one already exists...'

ios - 我想要一个用于核心数据的通用 fetchedResultsController 来支持多个模型

ios - Xcode 5.1.1 安装 CocoaPods 时出错

iphone - 如何只运行一次代码?

objective-c - iOS 中弃用的常量

ios - SWIFT:尝试使用 objective c 类的委托(delegate)方法

iOS - 使用数字序列初始化 NSArray

c - Xcode 4.3.3 上的预期标识符或 "("

ios - 动态更改自动布局