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.

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).

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.

Thanks in advance!

EDIT: 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.

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.

The links you provided are broken. The first now links to a travel site and the other is a 404.
–
SamMay 24 '13 at 23:18

@RazorSharp - Mike's whole website appears to have gone offline, so the closest implementation I could find was Drew McCormack's design of something similar which he based on Mike's original code.
–
Brad Larson♦May 25 '13 at 17:26

It's overkill for your purposes (as it contains a largely-complete board and card game reference app), but check out this sample from ADC. The card games included with it do that flip effect quite nicely.

The cards in this sample are layers that have images supplied as their contents. I need to put controls (buttons, text fields, views) on the layers and I can't seem to find a nice way to do that.
–
user46747Dec 16 '08 at 17:43

If you are able to do this with images, perhaps you can keep all of your controls in an NSView object (as usual), and then render the NSView into a bitmap image using cacheDisplayInRect:toBitmapImageRep: just prior to executing the flip effect. The steps would be:

Yeah. That's exactly the solution I was trying to avoid, or at least, avoid implementing it myself. I suspect that this is exactly what the Dashboard Widgets do as you can see it freeze and update. I was just hoping there was an established method to this. Thanks for the NSView methods!
–
user46747Dec 16 '08 at 19:10

Probably not the case in 2008 when this question was asked, but this is pretty easy these days:

[UIView animateWithDuration:0.5 animations:^{
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.iconView cache:YES];
/* changes to the view made here will be reflected on the flipped to side */
}];