Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6121629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:48:21+00:00 2026-05-23T15:48:21+00:00

I am creating a custom view to generate navigation bar items. – (id)initWithNibName:(NSString *)nibNameOrNil

  • 0

I am creating a custom view to generate navigation bar items.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        UIView *backButtonView = [[UIView alloc] initWithFrame:CGRectMake(0,0,70,35)];
        UIButton *myBackButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
        [myBackButton setFrame:CGRectMake(0,0,70,35)];
        myBackButton.titleLabel.text = @"Back";
        myBackButton.backgroundColor = [UIColor yellowColor];
        myBackButton.titleLabel.textAlignment = UITextAlignmentCenter;
        myBackButton.titleLabel.textColor = [UIColor blackColor];
        [myBackButton setEnabled:YES];
        [myBackButton addTarget:self.navigationController action:@selector(moveBack:) forControlEvents:UIControlEventTouchUpInside];
        [backButtonView addSubview:myBackButton];
        [myBackButton release];
        UIBarButtonItem* backButton = [[UIBarButtonItem alloc] initWithCustomView:backButtonView];
        self.navigationItem.leftBarButtonItem = backButton;
        [backButtonView release];
        [backButton release];


        CGRect frame = CGRectMake(300, 0, 400, 35);
        UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
        label.backgroundColor = [UIColor yellowColor];
        label.font = [UIFont boldSystemFontOfSize:20.0];
        label.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
        label.textAlignment = UITextAlignmentCenter;
        label.textColor = [UIColor blackColor];
        label.text = @"Order booking";
        self.navigationItem.titleView = label;
    }
    return self;
}  

With this I am having the following output :

enter image description here

I want the bar button to have same background color as navigation bar and its text in black color. I have tried doing it the either way by using UINavigationController delegate, but didn’t get success.
What changes do I need to make?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T15:48:21+00:00Added an answer on May 23, 2026 at 3:48 pm

    Read the 5.0 documentation. There was a WWDC ’11 session on this very thing about a new, and much easier way, to do this. (Session 114 – Customizing the Appearance of UIKit Controls).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating custom table view cells, but result is incorrect. My code: - (UITableViewCell
Im creating and adding a grid of buttons to my custom view keyboardView as
I am creating a Custom Grid kind of View for my App. I am
I am creating a UIBarButtonItem with a custom view in order to achieve a
I am creating a custom button and putting it in my table's footer view
I am creating a custom view which will have a bitmap so that user
I'm creating a custom view derived from GridView. This contains a custom ImageView with
I'm in the process of creating a custom view for my android application and
Is there a right/wrong approach for creating a Custom view using code or IB?
I'm looking for tutorials on creating custom view transitions. In particular, transitions that involve

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.