Are there ways to change the width of a UINavigationBar? Found a code (category) that changes the width of the bar, but the UINavigationBar remains in the middle. I can not find how to move it to the right.

- (CGSize)sizeThatFits:(CGSize)size { CGSize newSize = CGSizeMake(250, 44); return newSize; } 

    1 answer 1

    First of all, the question is why do you need it? Before you change the rigidly fixed dimensions of the elements should think twice.

    If to abstract it this question, the mechanism is quite simple - you need to make your successor from the UINavigationBar , specify what exactly it will be used, and not the standard bar. Well, after that you can already play with the size and position of this heir. Basically, I managed to move using the override setCenter:

     -(void) setCenter:(CGPoint)center{ center.x += kOffset; [super setCenter:center]; } 

    But I want to warn you right away, because this interference to the place where the Apple initially does not allow programmers, there is a chance to have hemorrhoids with support in different versions, I already had this - I tied something to the resize of some of the subviews (found using the subviews array ), and in the next version of OS 6.1 it stopped working because either they changed the hierarchy of species, or they simply scored, and the size of the species was always large and just sprinkled (I don’t remember any more)

    • and can even borrow money for that) - tragvar
    • by itself. But so far it’s not for me personally that I wasn’t re-enactable, although I did more than once such hacks: I rearranged the inscription with a picture on UIButton so that it was like on a toolbar, I made pictures on a navbar and a toolbar when it was still impossible to do (and it was on navbar, and not just Hid and put the picture as it was usually done), the buttons on the tabbara chased - aknew