Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Solution Like Trash Can Animation

I would like to put the undocumented trash can animation in my program. The call method is:

+ (void)animateToolbarItemIndex:(unsigned)index duration:(double)duration target:(id)target didFinishSelector:(SEL)selector;

Can anyone figure out what I should plug in for:

  • index
  • duration
  • target
  • selector ?

My trials are not working resulting in the error:

2011-11-15 16:05:20.639 CNiPhone[973:707] +[UIToolbar animateToolbarItemIndex:duration:target:didFinishSelector:]: unrecognized selector sent to class 0x3f019c08
2011-11-15 16:05:20.641 CNiPhone[973:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[UIToolbar animateToolbarItemIndex:duration:target:didFinishSelector:]: unrecognized selector sent to class 0x3f019c08'

Here is the relevant code:

@interface UIToolbar (privateMethods2)

+ (void)animateToolbarItemIndex:(unsigned)index duration:(double)duration target:(id)target didFinishSelector:(SEL)selector;

@end

    [UIToolbar animateToolbarItemIndex:0 duration:0.5 target:trashToolbarButton didFinishSelector:@selector(animateTrashStep2)];
    [UIToolbar commitAnimations];

- (void) animateTrashStep2 {
}
like image 910
T.J. Avatar asked Dec 28 '22 11:12

T.J.


1 Answers

You dont need to do any undocumented stuff for this, just create a custom UIButton. Download the UIKit Artwork Extractor and you'll find the frames for the trash can animation, as well as the UIBarButtonItem background.

like image 80
John Estropia Avatar answered Jan 15 '23 09:01

John Estropia