Customizing UINavBar with custom color and without hairline - ios7

I want to set my navigation bar to the same color as my UITableViewCell(s), while also hiding the pixel line between the navigation bar and the cells.
The code I've used, in the AppDelegate didFinishLaunchingWithOptions, is this:
[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
[[UINavigationBar appearance] setShadowImage:[[UIImage alloc] init]];
[[UINavigationBar appearance] setBackgroundColor:[UIColor colorWithRed:0.465639 green:0.763392 blue:1 alpha:1]];
It removes the pixel line and sets the Nav Bar's color.
However, it leaves the status bar as transparent and my table view appears in the status bar when I scroll down.
How can I add the color to the status bar as well?
Thanks!

If its a solid colour you could always use:
self.navigationController.navigationBar.translucent = NO;
To stop the content going behind the bar
And use the new barTint property
self.navigationController.navigationBar.barTintColor = [UIColor redColor];

Related

MFMessageComposeViewController: Cannot Style "Cancel" Button in Dark Mode

I'm currently trying to style the "cancel" button that is in the top right corner (the navigation bar and the button are both grey) and I am having no luck. I've tried calling several different methods and none have worked. My project builds for iOS12.1 and I'm testing via iOS15.4. Here is what I've tried so far:
[[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
[UIFont fontWithName:#"Futura-Medium" size:17.0f],
NSFontAttributeName,
[UIColor blueColor],
NSForegroundColorAttributeName,
nil]];
MFMessageComposeViewController *messageController;
[messageController.navigationBar setTintColor:[UIColor blueColor]];
messageController = [MFMessageComposeViewController new];
[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:[NSArray arrayWithObject:[UINavigationBar class]]].tintColor = [UIColor RepublicBrightBlue];
The gray color for the button is likely coming from the global tint color for your application. This is by default AccentColor that comes within Assets (this is mapped via Build Settings). Note that you can define separate global accent colors for Any, Light, Dark
If you're just interested in styling this MFMessageComposeViewController the following worked for me to change the tint color for all views within the message view:
MFMessageComposeViewController *messageController = [MFMessageComposeViewController new];
[self presentViewController:messageController animated:true completion:nil];
[UIView appearanceWhenContainedInInstancesOfClasses:[NSArray arrayWithObject:[MFMessageComposeViewController class]]].tintColor = [UIColor redColor];
Which results in

Navigation bar keeps turning into gray despite changing it to white. Why?

I'm using this code to turn the "Back" button on a navigation bar to white, but it keeps making it gray.
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
I also tried this:
[[UINavigationBar appearance] setTintColor:UIColorFromRGB(0xFFFFFF)];
I've also tried (I found it in another question):
[[UINavigationBar appearance] setTintColor:[UIColor colorWithWhite:1.0 alpha:1.0]];
None of them work! They keep making it gray! If I try red/black/green or another color, they work, but white keeps turning into gray.
Try it like this...
UINavigationController *controller= [[UINavigationController alloc]
initWithRootViewController:YourViewController];
controller.navigationBar.tintColor = [UIColor whiteColor];

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

Remove TabBar Button glow(not on image- hiding the selection tint of button)

I've created a tabbar application,I am using a custom TabBar with a backGround image.
I have finished all the parts but unable to remove the glow of tabbar button on click(i just changing the UIButton selection on click,but glow is still there)
How to hide the glow of UITabBar Buttons(ie hiding the selection tint of buttons) ?
Now TabBar is like this..
Need tabBar like this
You can use the following code.
[[UITabBar appearance] setSelectionIndicatorImage:[[UIImage alloc] init]];
Try It.
To change tabbar tint colour
[[UITabBar appearance] setSelectedImageTintColor:[UIColor grayColor]];
This will definitely help you. Simply create an UIImage object and pass it to setSelectionIndicatorImage property .
[yourTabbar setSelectionIndicatorImage:[[UIImage alloc] init]];
[self.tabBarController.tabBar insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"1.png"]] autorelease] atIndex:1];
You need to set UITabBarItem appearance:
[[UITabBarItem appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:[UIColor yellowColor], UITextAttributeTextColor,
[UIFont systemFontOfSize:14.0f], UITextAttributeFont,nil]
forState:UIControlStateHighlighted];

how to change the color of the tabbar controller

Is there any way I can change the Tab Bar Controller's color to something other than the default black? I know this isn't possible in IB, but perhaps maybe through code?
In AppDelegate
self.tabBarController.moreNavigationController.navigationBar.tintColor = [UIColor grayColor];
In AppDelegate.m in didFinishLaunching... method write(this will change for whole app):
[[UITabBar appearance] setBarTintColor:[UIColor myColor]];
Or you can write in ViewController.m in method viewDidLoad:
[self.tabBarController.tabBar setBarTintColor: [UIColor mycolor]];
You can do with XIB/Storyboard as well as programmatically
For Xib/storyboard select tab bar controller than tab and you can see all the options to change tab bar or tab bar view properties see the attached image Image attached here
For programmatically:
for tab bar tint and background
[[UITabBar appearance] setTintColor:panelColor];
[[UITabBar appearance] setBarTintColor:[UIColor lightGrayColor]];