Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 9    Views: 124

mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
01/30/14 12:20 PM (10 years ago)

BT30 - Day 26 - Shaking Menu Buttons Code

BT30 is my personal project to contribute to buzztouch: https://www.buzztouch.com/forum/thread.php?fid=2348BA49BA5737C92E3D9B5&tid=2348BA49BA5737C92E3D9B5 Day 26 - Shaking Menu Buttons Code ------------- DESCRIPTION ------------- This is a gem that was lost back in 1.4, long long time ago, this was what people considered gold before plugins were even a thing. It was shared by someone I do not remember anymore.. no credit to me. Altrhough its no longer "gold" it is still a highy customizable and fun tweak to add to your app that I'm sure almost no-one has used in a long long time. This code will make your buttons in the button menu plugin do animations! Shaking, fading, all that good stuff when you tap a menu button. It's cute and a fun way to make the button menu more interactive rather just a tap then > transition. Now its tap > animation (shaking button, fade in/out button, so on) > transition. This is truly a lost gem. Old BT members will remember how big of a deal this was. Enjoy! SEE IT IN ACTION!!! https://itunes.apple.com/app/ugadajka/id530550399?mt=8 Edit: not a free app, but totally worth the two bucks to see it in action. ------------- CODE ------------- If you replace in the BT_screen_menuButtons.m a David's variant of -(void)fadeView:(UIView *)theView{ //fade out... [theView setAlpha:buttonOpacity]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:.1]; [UIView setAnimationDelegate:self]; [theView setAlpha:0.5]; [UIView commitAnimations]; //then back in... [theView setAlpha:.1]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:.2]; [UIView setAnimationDelegate:self]; [theView setAlpha:1.0]; [UIView commitAnimations]; } with following: -(void)fadeView:(UIView *)theView{ CAKeyframeAnimation * animation = [ CAKeyframeAnimation animationWithKeyPath:@"transform" ] ; animation.values = [NSArray arrayWithObjects: [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(-5.0, 0.0, 0.0)], [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(5.0, 0.0, 0.0)], nil] ; animation.autoreverses = YES; animation.repeatCount = 7.0; animation.duration = 0.07; [theView.layer addAnimation:animation forKey:@"animateLayer"]; } you'll get something about earthquake effect. So, I would like to say you can use many and many different effects you like. Off course, the native BT script can consist only one effect, but you can create as many as you want, like me: -(void)earthquakeView:(UIView *)theView{ CAKeyframeAnimation * animation = [ CAKeyframeAnimation animationWithKeyPath:@"transform" ] ; animation.values = [NSArray arrayWithObjects: [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(-5.0, 0.0, 0.0)], [NSValue valueWithCATransform3D:CATransform3DMakeTranslation(5.0, 0.0, 0.0)], nil] ; animation.autoreverses = YES; animation.repeatCount = 7.0; animation.duration = 0.07; [theView.layer addAnimation:animation forKey:@"animateLayer"]; } //cat,cow -(void)zoomView:(UIView *)theView{ CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; animation.fromValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]; animation.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.2)]; animation.repeatCount = 1; animation.autoreverses = YES; animation.removedOnCompletion = NO; animation.fillMode = kCAFillModeForwards; animation.duration = .6; [theView.layer addAnimation:animation forKey:@"animateLayer"]; } in this situation you must add -(void)earthquakeView:(UIView *)theView; -(void)zoomView:(UIView *)theView; in the BT_screen_menuButtons.h DONE! ---------------------------------------------------- NOW - if you want multiple buttons to use different animations, use the below code, get the screen item id that the button goes to, and put it in there. This if code will invoke the specific animation you want to use for that button. If you delete/add it will change the id and will no longer work. ---------------------------------------------------- -(void)menuItemTap:(id)sender{ //cat,cow if([[BT_strings getStyleValueForScreen:thisMenuItem:@"loadScreenWithItemId":@""] isEqualToString:@"4F649FAFD0CA6BF6B711822"] || [[BT_strings getStyleValueForScreen:thisMenuItem:@"loadScreenWithItemId":@""] isEqualToString:@"FF73010054BA1975A9EDC68"]){ [self earthquakeView:tmpView]; } else if { [self zoomView:tmpView]; } } ------------- Hope this helps someone. David.
 
LA
Aspiring developer
Profile
Posts: 3278
Reg: Aug 16, 2012
Jerseyville, IL
42,880
like
01/30/14 01:02 PM (10 years ago)
Very nice! LA
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
01/30/14 03:34 PM (10 years ago)
Thanks mate. :-)
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/30/14 04:37 PM (10 years ago)
Sweet! Cheers! -- Smug
 
SheriDee
Code is Art
Profile
Posts: 1094
Reg: Sep 23, 2011
location unknow...
22,840
like
01/30/14 04:42 PM (10 years ago)
looks familiar thanks for the reminder :)
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
01/30/14 10:54 PM (10 years ago)
Broomla the wizard! http://www.buzztouch.com/broomla The technique was shared on Broomla's announcement of a Children's App. http://buzztouch.com/forum/thread.php?tid=B9532C2A6BBF4D25760FA27 I love seeing the enthusiasm of the BT'ers on that post. The crowd has evolved quite a lot since those days. Yet, we don't see much animation in a BT app. Challenge accepted! :-) -- Niraj
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
01/30/14 11:21 PM (10 years ago)
Niraj, awesome! I hope he makes his way back into the community, I bet he could build a few plugins that would for-sure stir up members again :-) Perhaps a little nudge will do! David
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
01/31/14 02:27 AM (10 years ago)
Shake'n right into my codebox thanks for the reminder David! Yeah Broomla is a ninja no doubt, I'm sure he is just sharpening his knives before coming back lol
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
01/31/14 08:08 AM (10 years ago)
Definate gem. His phrasebook apps were just as amazing and so well designed. Are you guys keeping a BT-30 Codebox? I've put a few snippets in my codebox, but it's not organized into a BT-30 folder. That might be a good share. I'd love to see codebox become a standard @ here for sharing code. Codebox would be a great place for David to put all those built in BT methods he created and said he hoped to document someday.... Thanks MrDavid :)
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
01/31/14 09:58 AM (10 years ago)
Yes codebox would be a nice asset.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.