Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 6    Views: 125

chadh0130
Apple Fan
Profile
Posts: 352
Reg: Nov 05, 2011
Rhode Island
4,020
02/14/15 08:11 PM (9 years ago)

Tutorial: replace nav bar title text with a custom image

I wanted to show this neat little customization with the bunch as it's been extremely helpful to me over the years. As some of you may know, I'm a big design guy so I always strive to make my apps have an awesome UI/UX to them. This tutorial will teach you how to replace the boring title text in the nav bar PER plugin...that's right PER plugin. You can use different navbar title images through your app depending on plugin use. Note: this is for ios only. Step 1: In the viewDidLoad method of the plugin, add: UIImage *image = [UIImage imageNamed:@"image.png"]; self.navigationItem.titleView = [[UIImageView alloc] initWithImage:image]; Step 2: Now in the viewWillAppear method, add: UIImage *imagetitlel = [UIImage imageNamed:@"ENTER_IMAGE_NAME_HERE"]; self.navigationItem.titleView = [[UIImageView alloc] initWithImage:imagetitlel]; Note: In step 2, replace ENTER_IMAGE_NAME_HERE with your file name without the file format. For example: twitter32 instead of twitter32.png That's it. Now go have some fun with it.
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
02/15/15 01:51 AM (9 years ago)
Awesome work! and looks soooooo simple!
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
02/15/15 07:14 AM (9 years ago)
Nice tip, Chad! What is the recommended size (height-width pixels) for the image? Does the iPhone 4,5,6 device type require @1x,@2x,@3x variations for the image? Would iPhone and iPad be different sizes? Do the Portrait and Landscape orientations matter for the sizes? Thanks for sharing that tip! -- Niraj
 
chadh0130
Apple Fan
Profile
Posts: 352
Reg: Nov 05, 2011
Rhode Island
4,020
like
02/15/15 07:49 AM (9 years ago)
Hi Niraj, I always suggest using the recommended @2x and @3x for retina displays. In regard to sizes, start with 174x40 and adjust as needed to get the look you like. Here is a design cheat sheet for ios that I use as reference when creating graphics: http://ivomynttinen.com/blog/the-ios-7-design-cheat-sheet/
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
02/15/15 11:00 AM (9 years ago)
Thanks for this, one for my collection. Cheers, Alan
 
DJM
Lost but trying
Profile
Posts: 50
Reg: Aug 20, 2013
planet earth
500
like
02/20/15 03:40 PM (9 years ago)
I need this for Android, any ideas?
 
chadh0130
Apple Fan
Profile
Posts: 352
Reg: Nov 05, 2011
Rhode Island
4,020
like
02/20/15 04:59 PM (9 years ago)
@DJM - I'm not a very proficient java developer so unfortunately I don't know how to accomplish the same effect. Once I get my ios plugins completed then I'll try dabbling around in java to see what I can come up with.
 

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.