动画的的NSView [英] Animations for NSView

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

问题描述

我一直在为iOS应用,并已开始制作那些用于Mac OS X最近。我试图做的NSView一些动画。

I have been making apps for iOS and have started making ones for Mac OS X lately. I am trying to do some animations on NSView.

我想要做的是反弹的一个规模如此的NSView它缩小到70%,然后回到100%的反弹。现在我能做的规模/尺寸零件,但它的动画位,我不能现在就做。

What I want to do is bounce the scale an NSView so it shrinks to 70% and then back to 100% with a bounce. Now I can do the scale/sizing parts, but it's the animation bit I can't now do.

使用的iOS我会用对的UIView如下:

With iOS I would have used the following on UIView:

+ (void)animateWithDuration:(NSTimeInterval)duration
                 animations:(void (^)(void))animations
                 completion:(void (^)(BOOL finished))completion

使用此就意味着当previous动画完成我就可以开始新的。我一直在寻找,我发现的Mac OS X相似的功能如下:

Using this it means when the previous animation finishes I can start the new one. I've been looking for a similar functions for Mac OS X. I've found the following:

[NSAnimationContext beginGrouping];
[[NSAnimationContext currentContext] setDuration:2.0];
// Set end state of objects to animate
[NSAnimationContext endGrouping];

这是类似于我用来制作动画的iOS 4之前的对象但后来动画块(如显示在顶部)的方式进行了介绍,我一直在使用他们至今。所以我的问题是,是否有针对Mac OS X的动画块,我已经错过了吗?或是否有这样做的另一种方式?

This is similar to the way I used to animate objects before iOS 4. But then animation blocks (like show at the top) were introduced and I've been using them ever since. So my question is, are there animation blocks for Mac OS X that I've missed? Or is there another way of doing it?

推荐答案

如果您使用的是Mac OS X 10.7,你可能会发现它更自然地使用基于块-NSAnimationContext API:

If you are using Mac OS X 10.7 you probably will find it more natural to use the blocks-based NSAnimationContext API:

+ (void)runAnimationGroup:(void (^)(NSAnimationContext *context))changes
        completionHandler:(void (^)(void))completionHandler

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

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