动画objective-c的对数刻度 [英] Logarithmic scale for animation objective-c

查看:40
本文介绍了动画objective-c的对数刻度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让一个圆在前 1-2 秒内快速扩展,然后随着它的增长速度降低.我认为对数刻度最适合于此,但我不知道如何创建一个.我正在使用以下代码为圆圈设置动画:

I'm trying to make a circle expand quickly for the first 1-2 seconds and then decrease in speed by which it grows. I thought that a logarithmic scale would be best suited for this, but I don't know how to create one. I'm using the following code to animate the circle:

// Create a view with a corner radius as the circle
self.circle = [[UIView alloc] initWithFrame:CGRectMake(currentPos.x, currentPos.y, 10, 10)];
[self.circle.layer setCornerRadius:self.circle.frame.size.width / 2];
[self.circle setBackgroundColor:[UIColor clearColor]];
self.circle.layer.borderColor = [UIColor redColor].CGColor;
self.circle.layer.borderWidth = .5f;
UIPanGestureRecognizer *move = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePan:)];
[self.circle addGestureRecognizer:move];
[self.view addSubview:self.circle];

[UIView animateWithDuration:5 delay:0 options:UIViewAnimationOptionAllowUserInteraction animations:^(void){

    // Animate it to double the size
    const CGFloat scale = 2;
    [self.circle setTransform:CGAffineTransformMakeScale(scale, scale)];
} completion:nil];

推荐答案

最简单的方法是使用内置的动画选项,可以设置动画的缓动(UIViewAnimationOptionCurveEaseOut)

The easiest way is to use the built in animation options, you can set the animation ease (UIViewAnimationOptionCurveEaseOut)

[UIView animateWithDuration:2 delay:0 options:UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionAllowUserInteraction animations:^(void){

    // Animate it to double the size
    const CGFloat scale = 2;
    [self.circle setTransform:CGAffineTransformMakeScale(scale, scale)];
} completion:nil];

这些是内置的缓动类型:

These are the built in ease types:

如果你想要一些与此不同的东西,那么我相信你需要自己做.

If you wanted something different to this then you'd need to do it yourself I believe.

感谢这篇文章提供了轻松的图片如何使用 Core Animation 创建自定义缓动函数?

Thanks to this post for the ease images How to create custom easing function with Core Animation?

这篇关于动画objective-c的对数刻度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆