Westley
Westley

Reputation: 1153

How can I make a UINavigationController that is not full screen in width?

I am trying to implement the Facebook style behind-view menu navigation pattern (using viewDeck) and I am having trouble making the navigationController behind the main view be less wide than the width of the screen.

Being that there is still some overlay from the main view, I need my navController to only be 276 pts wide. This means that the right side of the navController would be flush up against the ledge of the partially visible main viewController.

How can I narrow my navController for purposes of drilling into views when behind the main view? Is it possible? Everything I have tried so far just makes the navigationBar full screen.

EDIT 1: Testing with the PKRevealController:

enter image description here

As you can see, the text goes of the screen and you can't see the end of it. If you toggle the ledge a bit you can see the behind-view navBar goes all the way to the edge.

Upvotes: 3

Views: 1598

Answers (2)

wattson12
wattson12

Reputation: 11174

Its possible to create a UINavigationController which is less than the width of the view it is contained within. I had a quick look at the library you are using and it seems that the frame of each subview is set to the size of the window, offset by some amount to the left or right (see the functions for referenceBounds, centerViewBounds and sideViewBounds)

To change your navigation controller to be fully visible you need to change it so that the origin is the same and the width is 276.0f, so I think you will need to modify the sideViewBounds method to return a slightly smaller CGRect

Upvotes: 1

tilo
tilo

Reputation: 14169

If you want to reimplement the behaviour of the Facebook app, you may want to save some time and have a look at one of the following projects:

Upvotes: 1

Related Questions