Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 6    Views: 114

Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
07/04/15 04:52 PM (9 years ago)

(tutorial) Put a logo onto TabBar

After perusing the Internet and marveling at all the Buzztouch layout code and trying to keep all my changes only within the appDelegate.m file ... All the while I was duking it out with the Prof on my shoulder scolding me for modifying untouchable code. Well ... if we don't modify, we don't learn ... right? And learn I surely did! I was trying to avoid making changes that will have to be re-inserted each time I do a new Project Download from BtCentral. That is a maintenance nightmare! Many hours later ... I've stumbled onto a fine way to keep most customizations within a plugin. The end result is having total control without modifying any of the BT-provided code. The Need ------------- I have to put a Logo on the TabBar of an iPad app. The Logo should be visible on every screen, within every tab. Instead, make your own plugin. Put all of your customizations into that plugin. Then make that plugin be the first one to be launched before your Home Screen is shown. What plugin gets launched first? The Splash Screen plugin! The Technique ------------------ 0. Insert Logo.png into your Xcode project 1. Start with the Splash Screen plugin -- open the bt_screen_splash group folder within Xcode side column. 2. Edit BT_screen_splash.m 3. Find the viewDidLoad method 4. Scroll to the bottom of it, which ends right before the viewWillAppear method 5. Before the ending brace } place this code: // Overlay the logo onto right-side of tabbar UIImageView *logoView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Logo.png"]]; [logoView sizeToFit]; // Determine sizes of logo and tabbar int logoHeight = logoView.frame.size.height; int logoWidth = logoView.frame.size.width; int tabBarHeight = appDelegate.rootApp.rootTabBarController.tabBar.frame.size.height; int tabBarWidth = appDelegate.rootApp.rootTabBarController.tabBar.frame.size.width; // Calculate where to place logo within TabBar int frameX = tabBarWidth - logoWidth - 26; int frameY = (tabBarHeight/2) - (logoHeight/2); // Preset the logo position and size [logoView setFrame:CGRectMake(frameX, frameY, logoWidth, logoHeight)]; // Insert logo into the TabBar [[appDelegate.rootApp rootTabBarController].tabBar addSubview:logoView]; } // End of viewDidLoad ----------------- // Start of viewWillAppear -(void)viewWillAppear:(BOOL)animated{ Have fun! -- Niraj
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
07/04/15 04:55 PM (9 years ago)
Of course, in the Themes section of BtCentral, you should specify a Splash Screen. That way, your modified Splash Screen plugin will be launched. First it will show your specified Splash Image. Then it will show the Logo on the TabBar of your application. Ta-da! :-) -- Niraj
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
07/04/15 05:10 PM (9 years ago)
A. Remember to put your Logo.png into the Xcode project B. Specify you want a Splash Screen on BtCentral by going to the Themes section of the App C. The TabBar on iPad is wide enough to overlay most logos. The Logo should be separated far enough away such that it won't be confused with the Tab Items. D. Future improvement -- make the Logo be tappable to bring up a URL-based screen to the Company's web site. (that can be a good and bad thing, requires careful thought before acting) -- Niraj
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
07/04/15 06:01 PM (9 years ago)
Very cool! I was just looking at a plugin that I needed, but decided against it because it used a modified splash screen, and with this particular plugin, I would need more than one instance... but since it's a splash screen, it wasn't possible. This mod only needs to house one constant (the logo), so the splash screen makes perfect sense to use as a jump off point. Well done!
 
ianJamesPiano
Code is Art
Profile
Posts: 2661
Reg: Feb 13, 2011
Palm Springs, C...
37,010
like
07/04/15 09:18 PM (9 years ago)
Dude thanks! super useful!
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
07/05/15 09:53 AM (9 years ago)
Nice tutorial, thanks.
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
07/06/15 05:58 PM (9 years ago)
Outstanding idea. Thanks for the how-to Niraj!
 

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.