Reputation: 12717
I have a project where a custom height navigation bar is used across the app so it is 62px instead 44px tall. I am trying to build and layout my views using the storyboard editor (interface builder) although when using the Top Bar attribute set to Navigation Bar under the simulated metrics under the view controller options, this turns to be the default 44px one and not the custom height navbar (64px) I want.
This way all the view work area shows up on a different size and I always need to calculate what is going to exceed or not.
Is there any way that I can use both simulated metrics and a custom height navbar subclass gracefully while keeping the exact height I will have to work on the remaining space?
Upvotes: 1
Views: 1666
Reputation: 229
I'm afraid you can't really do that, if you want to have a similar behavior and a correct auto layout and constraints directly in Interface Building add a simple view for your custom navbar class with the correct metrics, (it will work just fine as the navigation bar inherits from UIView) just add the view, set the custom class, and add the constraints for both, the navigation bar and the top objects of your view.
Upvotes: 0
Reputation: 3001
It is not possible to change the Simulated Metrics to custom values by Xcode. A possibility is to design the custom navbar and copy it everywhere instead of the navigation, but then it is not simulated any longer. Or you could make a little hack by going into
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/PrivatePlugIns/IDEInterfaceBuilderCocoaTouchIntegration.ideplugin/Contents/Resources
and open CocoaTouchConstraints.plist
In this file you can set the value of NavigationBar
to the desired values. So if you want a Navigation Bar that is 60 high just set Maximum and minimum height to 60:
<key>NavigationBar</key>
<dict>
<key>MaximumSize</key>
<string>{10000, 60}</string>
<key>MinimumSize</key>
<string>{0, 60}</string>
</dict>
After saving you need to restart Xcode and you NavigationBar will have the desired height.
Upvotes: 4