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

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

问题描述

我正在尝试制作一个 Card 类,它可以复制 Dashboard 小部件的行为,您可以在卡片的两侧放置控件或图像或任何内容,并在它们之间翻转.

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.

支持图层的视图有一个变换属性,但是改变它并没有达到我期望的效果(围绕 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.

有人知道如何做到这一点吗?我觉得很奇怪,一个简单的小部件在 Core Animation 中很难做到.

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.

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

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