Discussion Forums  >  Status Bar, Navigation Bar

Replies: 10    Views: 233

nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
03/13/13 02:19 AM (11 years ago)

changing the back button image

http://dl.dropbox.com/u/2452503/back_button_image.jpg BT_viewUtilities.m From this: //line 326 //navLeftTap or closeChildApp UIBarButtonItem *theBackButtonItem = theBackButtonItem = [[UIBarButtonItem alloc] initWithTitle:backText style:UIBarButtonItemStylePlain target:theViewController action:@selector(navLeftTap)]; [theViewController.navigationItem setLeftBarButtonItem:theBackButtonItem]; [theBackButtonItem release]; --------------------------------------------- To this: UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; UIImage *backButtonImage = [UIImage imageNamed:@"navbar-back"]; [backButton setBackgroundImage:backButtonImage forState:UIControlStateNormal]; [backButton addTarget:theViewController action:@selector(navLeftTap) forControlEvents:UIControlEventTouchUpInside]; backButton.frame = CGRectMake(0, 0, 55, 30); [backButton setTitle:@" Back" forState:UIControlStateNormal]; UIBarButtonItem *theBackButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];; [theViewController.navigationItem setLeftBarButtonItem:theBackButtonItem]; [theBackButtonItem release];
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
03/13/13 02:54 AM (11 years ago)
Awesome! Do you know how to use a custom image for a right navigation bar button as well?
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
03/13/13 02:58 AM (11 years ago)
I should be able to figure it out. Will be looking at that in the next couple of days.
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
03/13/13 03:28 AM (11 years ago)
I should be able to figure it out. Will be looking at that in the next couple of days.
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
03/13/13 03:36 AM (11 years ago)
I'm interested in this also.
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
03/13/13 04:00 AM (11 years ago)
Line 366 in BT_viewUtilities.m is where the right button code starts
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
03/13/13 04:02 AM (11 years ago)
Do something similar as above after line 407
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
03/13/13 05:01 AM (11 years ago)
awesome post! thanks for the trick :)
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
03/13/13 12:34 PM (11 years ago)
Nad, Thank You! Cheers! -- Smug
 
Rohan
Veteran developer
Profile
Posts: 79
Reg: Mar 12, 2011
London
10,040
like
03/13/13 02:02 PM (11 years ago)
Really cool - been trying to this this for ages. I ammended the code slightly to control font size and font colour: UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; UIImage *backButtonImage = [UIImage imageNamed:@"backbutton.png"]; [backButton setBackgroundImage:backButtonImage forState:UIControlStateNormal]; [backButton addTarget:theViewController action:@selector(navLeftTap) forControlEvents:UIControlEventTouchUpInside]; backButton.frame = CGRectMake(0, 0, 55, 30); [backButton setTitle:@" Back" forState:UIControlStateNormal]; // define fontsize [backButton setFont:[UIFont boldSystemFontOfSize: 12]]; // Alternative code below to define a specific font // [backButton setFont:[UIFont fontWithName: @"Helvetica" size:12.0]]; // Set the Text Color [backButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [backButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
 
nadthevlad
Code is Art
Profile
Posts: 1025
Reg: Jun 07, 2012
Denver
21,850
like
03/13/13 02:58 PM (11 years ago)
Thanks Rohan.
 

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.