UITabbar with partially transparent background - 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.

Related

Navigationbar white tintcolor looks gray

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] }];

Setting UITableViewCellStyle2 Tint Color

I can't believe I don't see this anywhere on Google, but I have an odd issue.
I am changing the Global Tint in iOS 7 in the App Delegate:
[[UIView appearance] setTintColor:[UIColor redColor]];
However, when I display a table view with UITableViewCellStyle2 cells, the text title color is still the default blue color.
Any ideas on how I could fix this? I'd rather not subclass it.
Thanks!
simply change the text color.
cell.textLabel.textColor = [UIColor redColor];

How can I make my navigation bar uniformly semi-transparent?

I'm writing an app on iOS 7, and I can't seem to get a handle on the transparency of the navigationBar and the toolbar, how can I set the navigation bar to black at 50% opacity?
I've read the transition to ios7 guide and I've watched the wwdc13 lecture 214, but my status bar still has a different transparency than the rest of the attached nav bar.
Here is my code:
// APP-WIDE THEMING
[[UINavigationBar appearance] setBarStyle:UIBarStyleBlackOpaque];
[[UINavigationBar appearance] setBackgroundColor:[UIColor blueColor]];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
Here is the screenshot of my problem: http://grab.by/qiyU
Set the background image to nil, and set the background color with alpha.
[ctrl.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
ctrl.navigationController.navigationBar.backgroundColor = [UIColor colorWithRed:0 Green:0 Blue:0 Alpha:.5];
According to the answer posted here it's possible to create a transparent UINavigationBar:
How to draw a transparent UIToolbar or UINavigationBar in iOS7
However you want to create a semitransparent navigationbar. For that as far as I can tell you have to create a 1 px large image containing a black color with 50% opacity. Add this as backgroundimage for your Navigationbar.
This snippet should do the trick:
[[UINavigationBar appearance] setBarStyle:UIBarStyleDefault];
UIImage* sti = [UIImage imageNamed:#"EMT_SemiTransparent.png"];
[[UINavigationBar appearance] setBackgroundImage:sti forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setBackgroundColor:UIColor.clearColor];
try setting key [View controller-based status bar appearance] to NO in your pList file as well.
i've run into some funkiness with the status bar not seeming to be affected by changes in code and this solved it for me.
reference: https://stackoverflow.com/a/18184831/2962193
Set the alpha value to make it transparent.
[[UINavigationBar appearance] setAlpha:0.5f];

UiBarButtonItem Same Color as "Done" Button

I want to be able to programatically add a UIBarButtonItem to a Navigation Bar and set it's tint color to the exact same blue shade as Apple's "Done" UIBarButtonItem.
I am already doing this for Apple's red shade in this block of code:
UIBarButtonItem *myDeleteButton = [[UIBarButtonItem alloc] initWithTitle:#"Clear" style:UIBarButtonItemStyleBordered target:self action:#selector(myDeleteItemsMethod:)];
myDeleteButton.tintcolor = [[UIColor alloc] initwithRed:1 green:0.0470275 blue:0.0116515 alpha:1];
self.navigationItem.rightBarButtonItem = myDeleteButton;
I guess all I need are the RGB values.
I'm having a hard time trying to "reverse engineer" a UIBarButtonItem's tint that was made in Storyboard (Can't cast UIColor as text).
And I also realize that Xcode's color palette has an area for "developer" color schemes but it does not appear to include the color for the "Done" button.
I spent about 15 mins with my DigitalColor Meter and basically guessed and checked until I finally got it. The problem is that you're adding a "tint" to a black button to make it blue, so it won't be the right blue. Here's the correct measurements:
[buttonName setTintColor:[UIColor colorWithRed:34.0/255.0 green:97.0/255.0 blue:221.0/255.0 alpha:1]];
Hope it helps someone :)
You want UIBarButtonItemStyleDone rather than UIBarButtonItemStyleBordered.
The proposed color of user1641653 is just the bottom color of the real DoneButton taken with the color meter. The problem is that the shadow of a plain/borderer button is different than the one of a SystemButton. The shadow will change the proposed color by -11, -36, -11.
So if you really want it to look like the real DoneButton you have to add those values to the proposed 34/97/221.
This means:
[yourButton setTintColor:[UIColor colorWithRed:45.0/255.0 green:133.0/255.0 blue:232.0/255.0 alpha:1]];

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