iOS get other color than programed - ios

I want to change the color of the navigation bar.
I declared a variable called "mainColorBlue" and set the navigation bar to mainColorBlue.
UIColor *mainColorBlue = [UIColor colorWithRed:0.071 green:0.337 blue:0.533 alpha:1];
This is the color R18 G86 B136.
Now, if I launch the app on my device, but the color of the navigation bar is R39 G97 B139 and not R18 G86 B136
What I have to do, that the color is the same?

Make sure the tint color and the background color are the same. Nav bars can be weird with colors.

Related

Can you change the color of the UINavigationBar and status bar separately?

I have a view that I'm trying to 'dim'. I'm creating a UIView with a black background color and alpha of 0.4. I lay this view over my view, and I also change the color of my of navigationbar by change the RGB values (the correct way to get this is to take the RGB value and multiply it by 1.0-0.4 to get 0.6. Anyway, that's beside point).
I want to 'dim' my main view, and 'dim' the UINavigationBar... but I don't want the status bar to be 'dimmed'.
However, I can't figure out how to do this. When I change [self.navigationcontroller.navigationbar setBarTintColor:
Is there a way to set the colors individually?
Yes you're on the right track, You can set the color of the bar by using these methods, the barTintColor
//Navigation Bar
[self.navigationController.navigationBar setTitleTextAttributes:#{NSForegroundColorAttributeName : [UIColor whiteColor]}];
self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:53.0/255.0 green:53.0/255.0 blue:53.0/255.0 alpha:1.0];

How can I set the correct Nav Bar tint color?

I am creating a title view in my navigation bar. I designed my title view with background view color R:255 G:182 B:22 (on photoshop). In my storyboard, I've set the navigation bar tint color with the same RGB code, default style and translucent checked.
I put my image on my navigation title using:
UIImage *titleImage = [UIImage imageNamed:#"Icon-Small-40.png"];
self.navigationItem.titleView = [[UIImageView alloc]initWithImage:titleImage];
When I run the app, you can clearly see a square icon in the title view. The title view has a slightly darker background. I want to make the background the same color. I get the feeling that it has something to do with some storyboard setting but I can't find the issue.
the view has a tintColor property, so
self.navigationItem.titleView.tintColor = ...
Below answer for your navigation bar tint color
self.navigationController.navigationBar.tintColor = [UIColor greenColor];
Trying to make colours match up like this can be maddening. Colour space problems aside, the actual colour of the navigation bar isn’t guaranteed by the API to be the same as its barTintColor. You might find it easier to give the title image a transparent background.

Hard time setting color on status bar (iOS7) with transparency

I would like my status bar to be black and be 25% transparent. I understand that the status bar is transparent by default, and therefore takes on the color of the background. However when I set the views backgroundColor:
self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:.75f];
The status bar is completely black.
I have a toolbar which I set to black with an alpha of .75 and I am just trying to get them to match:
self.toolBar.tintColor = [UIColor whiteColor];
self.toolBar.barTintColor = [UIColor blackColor];
self.toolBar.alpha = .75f;
Any reason why the background color on the UIView is not respecting the alpha component?
EDIT:
Based on comment that view does not underlap the status bar. If I set background to green it shows that it works:
However if I start to add transparency to the green color, it does not get lighter it gets darker. Seems like the default is to be black underneath my only UIView, not white.
self.view.backgroundColor = [[UIColor greenColor] colorWithAlphaComponent:.25];
The status bar in iOS 7 is completely transparent. The problem may be that your view and the toolbar are not correctly underlapping the status bar. So you are seeing the black window behind it. (Or, in fact, you may setting the size of the window incorrectly, in which case you are seeing nothing at all behind the status bar.)
If the view does underlap the status bar, then you need to set the bar positioning of the toolbar to Top Attached so that its height increases up underneath the status bar. We should not be seeing a separate color for the status bar; it should appear to overlay your interface, lying in front of the top of the toolbar.

How to change iOS app's background image?

I want to change my app's whole background image to black, including the status bar and navigation bar, because I want to use black underpainting and gray font color. How can I do this?
You can change the view into UIButton, UILabel, UIImageView, etc.
view.backgroundColor = [UIColor blackColor];

Using global Tint color as UINavigationBars backgroundColor

i need to set the UINavigationBars background color to the same value as my apps global tint color.
problem here is that now all buttons in my navigation bar are the same color as its background. i now could change all UIBarButtons text color to white but this would be totally unusable. using the UIAppearance API doesn't seem to be a better way. after setting the text color of UIBarButton items to white, f.e the back arrows of the back button in my UINavigationBar are still painted with the global tint color.
also if i change the global tint color to white i loose all the flexibility that the global tint color gives us (also my text indicator would now be white and would not be seen on a white background)
what i want:
what i get using blue as global tint color
what i get when using blue as global tint color and setting uibarbutton items text color to white (see the back button - it should be white as well)
what is the recommended way to fix this problem?
I recommend that you do this:
UINavigationBar *navigationBar = [UINavigationBar appearance];
navigationBar.tintColor = [UIColor whiteColor];
Place this code in the didFinishLaunchingWithOptions: method in the AppDelegate.
For clarification as you are obviously not very experienced with this:
barTintColor is the property that would change the bar colour. tintColor changes the colour of interactive objects (such as the UIBarButtonItems)
if ([[UINavigationBar class] respondsToSelector:#selector(appearance)]) {
[[UINavigationBar appearance] setBarTintColor:[UIColor whiteColor]];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
}
Try to set UINavigationBar setTintColor in specified controller (in viewDidLoad for example).

Resources