1

I have a pop up window that slides on screen when a certain button is pressed.

This view has a custom look apart from the rest of the app. It has an .xib file as well. I have managed to change the header background color by adding a customClass to the toolbar in IB. I have managed to change the text style of the title text... It took me some time to figure that out. What I had to do was make an IBOutlet from the title item in IB, then apply the changes in my m...like so

 - (void)customizeAppearance
{



//Sets custom text attribures for this views headers text

[_customNavText setTitleTextAttributes:
    [NSDictionary dictionaryWithObjectsAndKeys:
        [UIColor whiteColor], UITextAttributeTextColor,  //sets text color
        [UIColor blackColor], UITextAttributeTextShadowColor, //sets text shadow color
        [NSValue valueWithUIOffset:UIOffsetMake(0, 3)], UITextAttributeTextShadowOffset, //Moves drop shadow by its coordinates
        [UIFont fontWithName:@"Helvetica-Bold" size:27.0], UITextAttributeFont,nil]  //sets text font and size
    forState:UIControlStateNormal];

}

and this function gets called once the view loads. So my text has its own style on this view only. Great.

So, maybe I am getting to picky, but now I want to move the text down a couple pixels.

This is what I did, I added the following code inside the customizeApperance function...

[[UIBarButtonItem appearance] setTitlePositionAdjustment:UIOffsetMake(25.0f, 25.0f) forBarMetrics:UIBarMetricsDefault];

But this does something interesting, it does not move my text down for the UIBarButtonItem I have just applied those styles too, instead it moves the text of the buttons on the nav bar, such as the cancel button.

So how do I move the UIBarButtonItem thats in the middle, containing text for the navigation header, rather than the text of the buttons on the side?

user1927446
  • 1,053
  • 8
  • 7
  • In your example code `[UIBarButtonItem appearance] ...`, I think you want to replace `UIBarButtonItem` with a variable pointing to the "middle UIBarButtonItem, containing text for the navigation header". As it is, you're calling the `appearance` and `setTitlePositionAdjustment` on the `UIBarButtonItem` class. – John Sauer Dec 27 '12 at 01:47
  • Hey check these links:- http://stackoverflow.com/questions/12078593/uinavigationbar-change-uibarbuttonitem-positions http://stackoverflow.com/questions/7350494/ios-changing-uibarbuttonitems-height – Nishant Tyagi Dec 27 '12 at 02:03
  • How would I add a variable pointing to that? – user1927446 Dec 27 '12 at 03:16

1 Answers1

0

I think you might be looking for:

[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:1 forBarMetrics:UIBarMetricsDefault];
Shaheen Ghiassy
  • 7,397
  • 3
  • 40
  • 40