I’m trying to set up a NavigationController from a Modal View, but I can’t figure out how to set the layout options using interface builder. Here’s the code I’m using.
//Create the view you want to present modally
UIViewController *modalView = [[UIViewController alloc] init];
//Create a new navigation stack and use it as the new RootViewController for it
UINavigationController *nav = [[UINavigationController alloc]
initWithRootViewController:modalView];
//Present the new navigation stack modally
[self presentModalViewController:nav animated:YES];
//Release
[modalView release];
[nav release];
Is there anyway to set the layout options of the navigationcontroller in interface builder? I tried setting the color using
nav.navigationBar.tintColor = [UIColor colorWithRed:128 green:0 blue:0 alpha:1];
but that results in a bright red instead of the maroon color this RGB combination is supposed to result in.
It would be much easier for me if I could control the NavigationController options from interface builder, is this possible given this setup?
Since you are creating these views programmatically, there’s nothing to set in interface builder. You can, however, programmatically set the tint color. Your problem is that the UIColor initializer takes floats between 1.0f and 0.0f for the intensity of the color. Your 128 is simply clamped to 1.0f, hence bright red. Try this instead:
That should give you a color closer to what you’re looking for.