小部件“翻转”核心动画/ Cocoa中的行为 [英] Widget "flip" behavior in Core Animation/Cocoa

查看:121
本文介绍了小部件“翻转”核心动画/ Cocoa中的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图制作一个Card类,复制仪表板小部件的行为,你可以把控件或图像或任何在卡的两面,并在它们之间翻转。

I'm trying to make a Card class that duplicates the behavior of Dashboard widgets in that you can put controls or images or whatever on two sides of the card and flip between them.

层支持的视图有一个transform属性,但改变它不会做我期望它做的(旋转层绕y轴折叠到左侧)。

Layer backed views have a transform property, but altering that doesn't do what I would expect it to do (rotating the layer around the y axis folds it off to the left side).

我被指向一些未记录的功能和一个名为cgsprivate.h的.h文件,但我想知道是否有一个官方的方法?这个软件将不得不发货,我不喜欢看到它失败,因为苹果的家伙在10.6中拉。

I was pointed to some undocumented features and an .h file named cgsprivate.h, but I'm wondering if there is an official way to do this? This software would have to be shipped and I'd hate to see it fail later because the Apple guys pull it in 10.6.

任何人都有什么想法如何做到这一点?对我来说很奇怪,一个简单的小部件在核心动画中很难做。

Anyone have any idea how to do this? It's so weird to me that a simple widget thing would be so hard to do in Core Animation.

提前感谢!

编辑:我可以完成这个行为与图层上的图像,但我不知道如何获得更高级的控件/视图/任何层。

I can accomplish this behavior with images that are on layers, but I don't know how to get more advanced controls/views/whatever on the layers. The card example uses images.

推荐答案

Mike Lee拥有翻转效果的实现,为此他已经释放了一些示例代码(不幸的是,这不再是在线可用,但是Drew McCormack 在他自己的实现中建立起来。)看起来他抓住了背景和前景视图进行交换,使用CATransform3D旋转动画中的两个视图,然后在动画完成后交换视图。

Mike Lee has an implementation of the flip effect for which he has released some sample code. (Unfortunately, this is no longer available online, but Drew McCormack built off of that in his own implementation.) It appears that he grabs the layers for the "background" and "foreground" views to be swapped, uses a CATransform3D to rotate the two views in the animation, and then swaps the views once the animation has completed.

通过使用从视图中,你避免需要缓存到位图,因为这是层正在做的反正。在任何情况下,他的视图控制器看起来是一个很好的解决方案,你想要的。

By using the layers from the views, you avoid needing to cache into a bitmap, since that's what the layers are doing anyways. In any case, his view controller looks to be a good drop-in solution for what you want.

这篇关于小部件“翻转”核心动画/ Cocoa中的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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