14

I'd like to use the UIView "sucking" transition (view is "sucked" into a point) referenced here:

http://iphonedevwiki.net/index.php/UIViewAnimationState#Using_suckEffect

The method above, however, uses private APIs, which makes it next to useless for an App Store app. How can I recreate a similar effect without relying on private APIs? I'm guessing the answer has to do with OpenGL, although I have zero experience there.

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
igul222
  • 8,557
  • 14
  • 52
  • 60
  • 3
    Great question (I don't have an answer) but it will be a great day when some clever graphics guy or gal puts out a drop-in library with high-quality suck/genie and page curling effects. Until then, I believe people largely just cook up their own (inferior) pseudo-versions. OK, so I don't have an answer, but you're likely to need to deal with rendering a texture on some geometry in openGL and animating the deformation. – Ben Zotto Apr 19 '10 at 01:45
  • possible duplicate of http://stackoverflow.com/questions/428110/how-can-i-replicate-the-trashing-animation-of-mail-app – kennytm Apr 19 '10 at 08:31
  • 1
    @quixoto: Yeah, that's the path I was planning on going down, though I'm still clueless as to which direction to start heading. @KennyTM: My question differs slightly in that I don't want to use private APIs. Is this still a duplicate? – igul222 Apr 19 '10 at 22:02
  • Sorry but I want to know how can i specify the corrner for this effect by default it take place in left-top corner of the device. Can I change it to right-top corner and how if I can !!! Thanks for the answer !!! – Viktor Apoyan Mar 10 '11 at 14:05
  • This will be a lame question but I didn't get - Where are we using private api in the link given by you ? [UIView beginAnimations:@"suck" context:NULL]; [UIView setAnimationDuration:3.0]; [UIView setAnimationTransition:103 forView:pageImageView cache:YES]; [UIView setAnimationPosition:CGPointMake(12, 345)]; [UIView commitAnimations]; – Akshay Aug 02 '11 at 07:10
  • "setAnimationTransition:103" is private - the 103 is blatantly trying to hide the use of the private call to the suck effect – Benjamin Mayo Aug 02 '11 at 22:20
  • `setAnimationTransition` is not private but `setAnimationPosition` is – yasirmturk Aug 20 '14 at 10:52

3 Answers3

7

As long as Apple doesn't publicly document the effect, and you want to avoid the risk of being rejected for using private API's you'll have to roll your own.

A suggestion to start working on this would be using OpenGL ES shaders.

The following blog post includes a demo Quartz Composer patch to create the Genie effect as seen in OS X and iOS: http://www.aderstedtsoftware.com/users/erik/weblog/c7cb9/

A good start for your OpenGL ES shader would be to use the code in the Genie Filter in this QuartzComposer file. The code can almost be copied to a shader for OpenGL as is. The most work would probably be integrating OpenGL in your application: rendering the right view to a OpenGL texture and overlaying OpenGL over your application to perform the animation based on your shader.

Joris Kluivers
  • 11,894
  • 2
  • 48
  • 47
3

Please have a look at my project at git://github.com/rmd6502/Genie.git - it's very slow right now, but improvements are forthcoming.

Robert Diamond
  • 1,155
  • 1
  • 14
  • 12
  • 2
    [Here](https://github.com/Ciechan/BCGenieEffect#bcgenieeffect) is something similar... but works faster – janisz Dec 27 '12 at 20:05
-3

have you checkked out the cocos2d framework. it's an objective c wrapper for openGL and it's done really well. you can check out their demo video which shows all the transition types that the library supports.

Remover
  • 1,616
  • 1
  • 17
  • 27