Navigationbar white tintcolor looks gray - objective-c

I am developing an application which supports iOS 7 and later, using navigationbar with bartintcolor of "green color". However, I got a problem when setting "tintcolor" to white. It became gray color instead of white (as shown in the image below).
Thanks,

I had the same problem and spent lots of time figuring it out.
Go to iOS Settings > General > Accessibility > Increase Contrast.
Turn off "Darken Colors" switch.

please add code below to your appdelegate file
[[UINavigationBar appearance] setTitleTextAttributes:#{ UITextAttributeTextColor: [UIColor whiteColor],UITextAttributeFont: [UIFont fontWithName:#"FONT_NAME" size:15] }];

Related

UISegmentedControl tint color isn't drawn correctly on iOS 7

I want to change the color of a UISegmentedControl on iOS 7. If I change the tint color in the Interface Builder, parts of it are drawn in the tint color, and parts are drawn in the standard blue.
The image ought to make this clearer. I have selected red as the tint color.
I get the same behaviour on both the simulator and on the device.
If I tap items on the segmented control, they're redrawn in the requested tint color.
If I specify the tint colour in viewDidLoad, everything works correctly.
[segmentedControl setTintColor:[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0]];
Why doesn't the Interface Builder color work?
(It feels like the color property hasn't applied correctly at the time the control is first drawn, but I have no evidence to back that up.)
I have the same bizarre behavior. The only workaround I could come up with was to switch the tintColor to something else and then switch it back in viewDidLoad
[self.mySegmentedControl setTintColor:[UIColor clearColor]];
[self.mySegmentedControl setTintColor:self.view.tintColor];
If you don't want to write code, there is another workaround that can be done in the storyboard.
Keep the tintColor of the view as the default. The segment control will work then. The downside is that you will have to set the tintColor for each component on your view.

Change MFMailComposeViewController's UINavigationBar color in iOS7

I am trying to update my app for iOS7, however I am unable to set the colour of the UINavigationBar at the top of the screen. I have tried the classic approach...
[mailer.navigationBar setTintColor:[UIColor darkGreyColour]];
...however it didn't work. I have also tried calling setBarTintColor instead, however that didn't seem to work either.
Does anyone know if its possible to set the colour and if so how?
I had your same problem when updating my application for iOS 7.
I solved using this line of code (if you use images):
[[UINavigationBar appearance] setBackgroundImage:#"myImage" forBarPosition:UIBarPositionTopAttached barMetrics:UIBarMetricsDefault];
or this one if you are not using images:
[[UINavigationBar appearance] setBarTintColor:[UIColor blueColor]];
I placed then in AppDelegate, just before returning application:didFinishLaunchingWithOptions:
Hope this helps!
Try changing the tint in storyboard. Its in 'view' sub section when you select navigation bar in IB.

Set default tint color for all UIButtons in an app

My iPad app I has a number of UIButtons that when pressed turn blue by default. I could go through each one and set the tintcolor using:
[buttonName setTintColor:[UIColor colorWithRed:151/255.0f green:202/255.0f blue:86/255.0f alpha:1.0]];
But is there anyway of changing this colour by default and for all buttons?
Is there anyway of changing this colour?
If you are using storyboards and Xcode 5.0 or later, the easiest way to do this is to open up your storyboard in Xcode and set the Global Tint color setting in the File Inspector in the Utility area. See illustration below.
Use the UIAppearance Protocol:
[[UIButton appearance] setTintColor:[UIColor colorWithRed:151/255.0f green:202/255.0f blue:86/255.0f alpha:1.0]];
You could subclass uibutton and set the color to whatever you want there. Then any button with that class will have the same color

UITabbar with partially transparent background

Long time reader, first time poster. Please be gentle :P
I'm working on an app and have a background image for a UITabbar element that is transparent for a few pixels at the top. I have searched far and wide, tried many solutions suggested that I could find (setting tint, background color to clearColor, setting alpha to 0.2, etc) but I continue to see a black line where the tabbar should be transparent. I am setting the background as follows (see the lines commented out for some more things I have tried which did not work)
//[[UITabBar appearance] setBackgroundColor:[UIColor clearColor]];
//[self.view setBackgroundColor:[UIColor clearColor]];
//[super.view setBackgroundColor:[UIColor clearColor]];
//UITabBar.super.setBackgroundColor:[UIColor clearColor]];
[[UITabBar appearance] setBackgroundColor:[[UIColor alloc] initWithRed:0 green:0 blue:0 alpha:0.2]];
//[[UITabBar appearance] setTintColor:[UIColor blackColor]];
[[UITabBar appearance] setTintColor:[[UIColor alloc] initWithRed:0 green:0 blue:0 alpha:0.1]];
//[[UITabBar appearance] setAlpha:0.0];// setTintColor:[UIColor magentaColor]];
[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:#"tabbar.png"]];
Screenshot can be fount at http://i.imgur.com/m1tW5.png
The app uses a tabbarcontroller.
When I set the background color to white or any other color, the black line changes color successfully but as soon as I set the color to clearColor the black line comes back.
When I hide the entire tab bar there is nothing crazy behind it and I can successfully see the cream background as I should.
The image is a png with a transparent top where the black line appears as mentioned earlier.
Does anyone have any suggestions on what I could be doing wrong?
Help will be truly appreciated.
Edit: I am using iOS 5.0 and don't care about supporting previous iOS versions (in case that opens up any additional potential choices).
I'm currently trying to solve a similar problem.
I believe the black color is either:
The TabBars Superviews background in which case you can try to set the tabBars superviews background color. I don't have my mac here so I can't try it and I don't see that in your "tried" code.
Or it's the border of the tabBar, in which you can change the bordercolor of the tabBar's frame.
tabbar.frame.borderColor = [UIColor whiteColor];
You will need to import the QuartzCore framework to manipulate the boderColor.
Let me know if it helps.
I decided to go with a "hack-ish" solution I came across elsewhere.
I'm using the same color as the background in areas of the tab bar's background image to create the illusion of transparency. Not really transparent but that's the best I could come up with after countless hours spent on this.
Maybe that'll be a solution that works for someone else in a similar position in the future as well.

Why is setting my UINavigationBar's background image affecting the size of the navigation bar?

I'm doing something like this:
UIImage *barBackgroundImage = [UIImage imageNamed:#"myImage.png"];
[[UINavigationBar appearance] setBackgroundImage:
backgroundImage
forBarMetrics:UIBarMetricsDefault];
And the resulting UINavigationBar is much larger than the standard navigation bar. I'm aware that my image size might be the problem. Is there any way to take care of this programmatically?
This is how I set the UINavigationController's navigationBar background image.
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:#"navbar.png"] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setTintColor:LIGHTBROWN];
navbar.png is 320x44 and respectively 640x88 for navbar#2x.png.
Follow this link to make your code compatible with iOS4, 5 and 6: http://robert-varga.com/?p=735
You just have to make in Photoshop or other software a rectangular with the size of 320x44 or 640x88 (for retina display) and import it to your project