views:

46

answers:

2

Does anyone know if the uinvagitionbar of a uinavigationcontroller can be moved down? I'd like to move it around 200 pixels down to have a logo on top. From my research, I understand that the navigationbar should not be subclassed and there are only two properties that should be changed, it's color and it's visibility. So is this impossible?

I tried moving it's frame, but to no avail.

I've seen other apps do it, but I'm thinking it might be a toolbar? Can the toolbar be repositioned?

Thanks

A: 

You can hide the self.navigationController and put another navigation bar in the code which will move according to your frame set.

Yes the tool bar can be repositioned. Just take a control in your code and set its frame as per your requirement.

Happy Coding...

Suriya
A: 

Just change the size of the frame of the navigations controller's view.


CGRect frame = navigationController.view.frame;
frame.size.height -= 200.0f;
frame.origin.y += 200.0f;
navigationController.view.frame = frame;

You can then add whatever view you'd like to the view or window that contains the navigationController's view.

There a few tricky things to consider if you plan on doing this by presenting a modal view controller, however.

Jerry Jones
This was what I was looking for! Thanks!
So it worked, but everytime the screen rotates it realigns back on top. Do I have to go to every view controller and change the didrotate method, or is there a simpler way to keep it fixed there? Thanks.
Does it have anything to do with the autoresizingmasks and autoresizesubview properties? I'm fiddling around with them but nothing is happening.
Are you displaying this navigation controller from your app delegate? Modally?
Jerry Jones
Yeah I allocate and display it in the app delegate, but not modally.UINavigationController* navigationController = [[UINavigationController alloc] init];[self.window addSubview:navigationController.view];Sorry, I don't know how to do the code quotes.
I think a solution would be to subclass uiviewcontroller for all of my viewcontrolers, and then have the four frames for the four orientations. Then, I will adjust the frame in the viewcontroller subclass's init, and didrotate? Is there a method to find the current orientation?
You should be able to set the frame size with a line of code just below the alloc/init and then addSubview.
Jerry Jones
Right, that works. But whenever I rotate the device the frame resizes back to the top. Any suggestions?
I even tried "navigationController.view.autoresizingMask = UIViewAutoresizingNone;" but that doesn't work either. Really stomped on this one.