Here is a n00b question, but one I can't seem to solve reading my books and notes:
I'm implementing a navigation control, and I can't figure out why my code is failing to set a tint color for it.
In my app delegate implementation file, under applicationDidFinishLaunching:
method:
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
rootViewController *rootView = [[rootViewController alloc] initWithNibName:@"rootViewController" bundle:nil];
self.navController = [[UINavigationController alloc] initWithRootViewController:rootView];
self.navController.navigationBar.tintColor = [UIColor colorWithRed:20/255 green:44/255 blue:86/255 alpha:1];
The navController
initializes just fine but with a black color.
You're seeing a black nav bar because [UIColor colorWithRed:20/255 green:44/255 blue:86/255 alpha:1]
is black!
You're performing integer division so 20/255 == 0
. Express those values as floats and you should see the color you expected:
[UIColor colorWithRed:20.0/255 green:44.0/255 blue:86.0/255 alpha:1]
This is black color, because you divide integers.
[UIColor colorWithRed:20/255 green:44/255 blue:86/255 alpha:1];
Try this:
[UIColor colorWithRed:20.0f/255.0f green:44.0f/255.0f blue:86.0f/255.0f alpha:1.0f];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With