Take the 2-minute tour ×

In my iPhone app, I have put a UIBarBUtton of type UIBarButtonSystemItemTrash in my UIToolBar. When pressed, I'd like to replicate the animation of Mail.app: the bin opens, the UIView folds and flies into it.
Is there a way to access this animation ithrough the iPhone SDK?

Presently I am using a custom made animation, but there are some limits; for example, I cannot animate the bin itself. Do you have any suggestion? Code samples?


share|improve this question
So, folks: How to do that without private API? –  dontWatchMyProfile May 23 '10 at 18:18
Hi nutsmuggler if am trying same animation i am not getting how to fold curve while moving ...... if possible tell how to do that –  jeeva Jan 18 '11 at 14:34
@jeeva haha i like how casually you mention his name –  Paul Shapiro Jun 30 '11 at 12:59

4 Answers 4

up vote 32 down vote accepted

Use the suckEffect type on an animation. Also: spewEffect, genieEffect, unGenieEffect, twist, tubey, swirl, cameraIris, cameraIrisHollowClose, cameraIrisHollowOpen, rippleEffect, charminUltra, zoomyIn, and zoomyOut. Doesn't work in the simulator.

CATransition *animation = [CATransition animation];
animation.type = @"suckEffect";
animation.duration = 2.0f;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
view.opacity = 1.0f;
[view.layer addAnimation:animation forKey:@"transitionViewAnimation"];

Note: Code snippet was pulled from a larger codebase. I hope it works :)

share|improve this answer
This is using private API. Don't be surprised if Apple rejects your app for including those effects, and especially don't be surprised if your app starts behaving strangely after an OS update. I strongly recommend you stay away from this. –  Kevin Ballard Jan 10 '09 at 12:15
Yup, it's very much a private API and is completely unsupported. The fallback for unknown animation types is a fade effect though so it's safe to use for in-house or open toolchain development. App Store approval is a mixed bag regarding private APIs but I doubt they'd reject this usage. –  rpetrich Jan 11 '09 at 3:54
I had this on my Apps, and AppStore approve it to be on Sale. may be this is not the private API. :-) –  Jirapong Jun 17 '10 at 3:27
Worth noting nothing is private but the string @"suckEffect". I'm not sure if specifying undocumented strings can be considered private API use. Certainly I wouldn't personally expect the private API detector tool Apple use to detect this. –  mxcl Dec 3 '10 at 11:41
this is really cool animation. i want to ask how did you know about undocumented features of iphone sdk...... –  Nirmit Patel Jan 18 '11 at 10:37

I'm not sure if this is an answer but here is lib that do "genie effect" so it's quite similar to what you want achieve

share|improve this answer

Just to add some info:

  1. You can use "suckEffect" with the standard +[UIView setAnimationTransition:forView:cache:]. Just pass the number 103 to the animationTransition variable. This won't avoid your app being rejected by Apple though :p
  2. "spewEffect", "genieEffect", "unGenieEffect", etc. no longer exist on iPhoneOS 3.x. The only undocumented transition left are "cube" (--), "rippleEffect" (110), the three "cameraIris" effects (105,106,107) and "suckEffect" (103).

See http://www.iphonedevwiki.net/index.php?title=UIViewAnimationState for detail.

Also, to animate the bin (with private API): http://www.iphonedevwiki.net/index.php?title=UIToolbar#Animating_the_trash_can_icon.

share|improve this answer
Thanks, very nice suggestion! –  nutsmuggler Jan 13 '10 at 15:54

Unfortunately, I think this is going to need to be an entirely custom animation. The UIView folding can be approximated using Core Animation, perhaps by adding perspective to the CATransform3D of the UIView's underlying layer to distort the UIView into a trapezoid which gets sucked into the trash can.

As far as the trash can, you can create a UIBarButtonItem using initWithCustomView:, which might let you insert a custom UIView that has an animatable trashcan. It looks like the trash can has two elements, the can base and the lid, which are rotated independently to open and close the can. Draw PNGs for both, make UIImageViews for them, and make them subviews of the UIBarButtonItem custom view. For opening and closing, apply rotational transforms to them to animate the subviews.

share|improve this answer
I was afraid I'd get this answer :) One thing I'm worried about is that replicating the Apple's apps beahviour too closely one might get his app rejected for accusation of using a private API. Also, I am not confortable grabbing Apple's own bin and retouching it, but maybe I'm just a scaredy cat. –  nutsmuggler Jan 10 '09 at 10:22
You have nothing to fear if you are creating your own implementation from published interfaces. You might get an initial rejection, but they will listen to your response and end up approving it. Frankly, the reports about complete rejection are way overblown. –  Brad Larson Jan 11 '09 at 13:50
That is true (maybe a very late response) .. most apps end up in the store one way or the other. –  not really Jake Jul 3 '09 at 8:11

protected by Will Jan 18 '11 at 14:34


Would you like to answer one of these unanswered questions instead?
