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

  • Home
  • SEARCH
  • 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 6873433
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:04:04+00:00 2026-05-27T04:04:04+00:00

After creating a custom view and assigning it to the navigationItem.titleView property it is

  • 0

After creating a custom view and assigning it to the navigationItem.titleView property it is displayed like this

enter image description here

with the custom view filling the space between the two buttons. Therefore, the custom view is not centered on the navigation bar. How do I determine the frame of the view in the .titleView property? I want to center some text in the navigation bar, say under the time stamp.

  • 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-27T04:04:04+00:00Added an answer on May 27, 2026 at 4:04 am

    If you really want to get titleView‘s frame (in your top-level view’s coordinate space), you can do this:

    [self.navBar layoutIfNeeded];
    CGRect titleViewFrameInTopLevelViewSpace = [self.navigationItem.titleView
        convertRect:self.navigationItem.titleView.bounds
        toView:self.view];
    

    You need to do layoutIfNeeded if you have just assigned titleView, because by default the navigation bar won’t lay out its subviews until the next pass through the run loop.

    That said, the titleView will be centered automatically, if it fits. I think you are setting the frame (or bounds) of your custom view too large. I tested this two ways:

    • I set up the titleView directly in the XIB. I simply dragged a View from the Object library onto the center of the navigation bar:
      XIB screen shot
      It sized the view to 128×33 automatically. The resize handles let me adjust the size. It stays centered until it overlaps the Categorize button. Then it shifts left.

    • I set the titleView property in viewDidLoad:

      - (void)viewDidLoad
      {
          [super viewDidLoad];
          UIView *customView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 33)];
          customView.backgroundColor = [UIColor greenColor];
          self.navItem.titleView = customView;
       }
      

      The result looks like this:
      Simulator screen shot

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

Sidebar

Related Questions

I like to custom edit the permission of users after creating or editing an
After creating a new form, I usually perform this ritual: Change the name into
After creating a div on the fly with this markup: $('.circuit').prepend(<div class='component' draggable='true'>TRANSISTOR</div>); It
I have such view that handles user registration. After creating new user i want
Is it possible to change the custom pen colour attribute after creating it using
Ive been using a custom class for some time like this in PS (2.0):
I am creating a custom MVC framework. I verrrrry loosely modeled it after the
I am having an issue with EmailReceived method with a custom list. After creating
I am creating a custom control and I need to handle some logic AFTER
After creating a custom Dialog using a ListView and my own implementation of ListAdapter

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.