Custom barTintColor for navigationBar
I'm trying to get a custom color for the app navigation bar and it doesn't work. The hex code for the exact color I need is blue # 023883. I looked at the rbg percentages from this site: http://www.colorhexa.com/023883 and the percentages: rgb (0.8%, 22%, 51, 4%). I put it in my code like this:
self.navigationController.navigationBar.barTintColor = [UIColor
colorWithRed:0.8 green:22 blue:51.4 alpha:1.0];
self.navigationController.navigationBar.titleTextAttributes =
@{NSForegroundColorAttributeName : [UIColor lightGrayColor]};
self.navigationController.navigationBar.backgroundColor = [UIColor
whiteColor];
self.navigationController.navigationBar.translucent = YES;
I also tried to implement a code that allows hexadecimal input for the color value, but that didn't work either. Is there any other way for me to achieve this color? (I also tried putting only blue at 100 and it still wasn't dark enough)
source to share
You forgot%, it must be
self.navigationController.navigationBar.barTintColor = [UIColor
colorWithRed:0.008 green:0.22 blue:0.514 alpha:1.0];
Edit, on how to make the statusBar white
- set this key to NO in info.plist file
View controller-based status bar appearance
. Click the icon to theplus
right of the Property Information List , then click the buttonV
in a new line, it will auto complete, this key will be the first -
In the application
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Override point for customization after application launch. [application setStatusBarStyle:UIStatusBarStyleLightContent]; return YES; }
source to share
Step 1
Please select NavigationController
Step - 2
divide Navigation bar
Step 3
you can get navbar attributes
Step -4 Here you can change Title
, Font
, Background color
etc.
statusBar - Transparent
Target
→ Genral
→ U get the following result change Status Bar Style
→ Light
please follow the image.
don't forget to set NO
to plist
String name ->View controller-based status bar appearance
source to share
You are using it colorWithRed:green:blue:alpha
wrong. You must enter percentages (0.8, 22, and 51.4 in your case), but you are entering them incorrectly.
Enter 0.008, 0.22 and 0.514 instead:
self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0.008 green:0.22 blue:0.514 alpha:1.0];
source to share