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 8778353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:30:59+00:00 2026-06-13T19:30:59+00:00

I am trying to add two labels – one on the left and one

  • 0

I am trying to add two labels – one on the left and one on the right of a UINavigationBar in my UIViewController implementation programmatically. However It doesn’t show up when I run my program. I have a UIViewController that is embedded in a UINavigationController. I am using following code:

- (void) setTheNavigationbarView{

    CGFloat originX = self.navigationItem.titleView.bounds.origin.x;
    CGFloat originY = self.navigationItem.titleView.bounds.origin.y;
    CGFloat sizeW = self.navigationItem.titleView.bounds.size.width;
    CGFloat sizeH = self.navigationItem.titleView.bounds.size.height;

    UIView * navigationbarView = [[UIView alloc] initWithFrame:CGRectMake(originX + 1, originY + 1, sizeW - 2, sizeH - 2)];
    navigationbarView.backgroundColor = [UIColor clearColor];


    UILabel *labelLeft = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, (sizeW - 2)/2, (sizeH - 2))] autorelease];
    labelLeft.backgroundColor = [UIColor clearColor];
    labelLeft.font = [UIFont boldSystemFontOfSize:16];
    labelLeft.adjustsFontSizeToFitWidth = NO;
    labelLeft.textAlignment = UITextAlignmentLeft;
    labelLeft.textColor = [UIColor blackColor];
    labelLeft.text = @"first line";
    labelLeft.highlightedTextColor = [UIColor blackColor];
    [navigationbarView addSubview:labelLeft];

    UILabel *labelRight = [[[UILabel alloc] initWithFrame:CGRectMake(((sizeW - 2)/2 + 1), 0, (sizeW - 2)/2, (sizeH - 2))] autorelease];
    labelRight.backgroundColor = [UIColor clearColor];
    labelRight.font = [UIFont boldSystemFontOfSize:16];
    labelRight.adjustsFontSizeToFitWidth = NO;
    labelRight.textAlignment = UITextAlignmentRight;
    labelRight.textColor = [UIColor blackColor];
    labelRight.text = @"second line";
    labelRight.highlightedTextColor = [UIColor blackColor];
    [navigationbarView addSubview:labelRight];

    // set the view as navigationba title view
    self.navigationItem.titleView = navigationbarView;
}

I will appreciate any help. Thanks.

  • 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-06-13T19:31:01+00:00Added an answer on June 13, 2026 at 7:31 pm

    I test your code and its work for me, i would only check if your frame is not bigger than every size of your navigaitonController.

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

Sidebar

Related Questions

I am trying to do this List<String> stringList = new ArrayList<String>(); stringList.add(one); stringList.add(two); stringList.add(three);
In this following code I intend to programmatically add two labels in each row
I'm trying to multiply (add/divide/etc.) two dataframes that have different column labels. I'm sure
I have been trying to add data labels to my pivot charts programmatically through
I'm trying to add two object that they are in the same class. In
I'm trying to add two inputs to a QTCaptureSession in the following: mainSession =
I am trying to add two larger binary numbers (i.e. number of bits are
I am trying to add two values in a byte array. This is my
I am trying to add two decimal values but the returned sum is pure
We have a situation where we are trying to add two UITableViews inside a

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.