Can I change the opacity of a UIBarButton item using UIAppearance? - ios

Im able to change the back button tint colour using this appearance proxy
//set back button tint
[[UIBarButtonItem appearance] setTintColor:[UIColor colorWithRed:56.0/255.0 green:75.0/255.0 blue:134.0/255.0 alpha:1.0]];
I want to know if it is possible to change the opacity of the back button?

This will allow the whole navigation bar to have some opacity
[self.navigationController.navigationBar setTranslucent:YES];

Related

How to make default tab bar as full transparent

Transperent imageI am working on a tab bar application.I applied the color to the tab bar like this
[[UITabBar appearance] setBarTintColor:[UIColor colorWithRed:137.0/255.0f green:27.0/255.0f blue:2.0/255.0f alpha:1.0f]];
My requirement is to display the tab bar transparent like below image
After applying the below code.tab bar is not displaying transparent. but it is displaying with black color background
self.tabBarController.tabBar.backgroundColor = [UIColor clearColor];
self.tabBarController.tabBar.translucent = YES;
Give suggestions for making the default tab bar as transperent
black color background image
You can create an empty image and pass it as a backgroundImage:
[[UITabBar appearance] setBackgroundImage:[UIImage new]];
You can use a similar approach for shadows and tint, but pay attention that a tint color is something very particular that has to deal with you whole UI.

In Objective C, while presenting a ViewController how to change the color of NavigationBar?

I am able to change tho color of NavigationBar by giving BackgroundColor but than I am not able change the color of StatusBar. Please provide a solution.
You should change the barTintColor instead of the background color.
[self.navigationController setBarTintColor:[UIColor redNavigationBarColor]];
Chances are that you will probably need to change also the barButton color and/or the the title color and all that should probably apply to more than one screen. So, to save you some time, if you want to globally change all these, put the code below in your app delegate
[[UINavigationBar appearance] setBarTintColor:[UIColor redColor]];
[[UINavigationBar appearance] setTitleTextAttributes:#{NSForegroundColorAttributeName : [UIColor whiteColor]}];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
The code above will give you a red navigation bar with white title & buttons

Slide Menu IOS Using aryaxt/iOS-Slide-Menu

I am trying to change Navigation bar background color in viewDidLoad using the same example in the link below but that's not working.
[[UINavigationBar appearance] setBackgroundColor:[UIColor greenColor]];
please help.
https://github.com/aryaxt/iOS-Slide-Menu
To change the NAv bar color, You have to use bar tint color:
self.navigationController.navigationBar.barTintColor=[UIColor greenColor];

iOS 7.1 UINavigationbar and UIToolbar

After upgrading Xcode in iOS7.1 my navigation bar and UIToolbar buttons are not shown with correct colour.
When a view first appears the UIToolbar buttons all have the correct default blue colour and when I go to next page/view and come back to the previous view the toolbar buttons are shown in a grey colour.
I have tried to add the blue colour in viewDidLoad and viewWillAppear but no luck. Can someone please help me?
Thanks.
You can set up a theme for certain components all at once and they will be used throughout your application. In my app delegate I created a function when the application is initializing called setupTheme, and it does just that - sets up the "theme" of the application by saying things like [[UINavigationBar appearance] setBarTintColor:], which in effect sets the color of the navigation bar for ANY navigation controller throughout the app. Here's an example from an app that sets up some basic components that are reused so that any time you use them they will already have the correct theme applied.
- (void)setupTheme {
// get our theme colors
UIColor *primaryThemeColor = [UIColor blueColor];
UIColor *secondaryThemeColor = [UIColor whiteColor];
// nav bar
[[UINavigationBar appearance] setBarTintColor:primaryThemeColor];
[[UINavigationBar appearance] setTintColor:secondaryThemeColor];
[[UINavigationBar appearance] setTitleTextAttributes:#{NSForegroundColorAttributeName:secondaryThemeColor}];
// tab bar
[[UITabBar appearance] setTintColor:primaryThemeColor];
// switches
[[UISwitch appearance] setOnTintColor:primaryThemeColor];
// search bar
[[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTitleTextAttributes:#{NSForegroundColorAttributeName: [UIColor blackColor]} forState:UIControlStateNormal];
}
Check out the iOS 7 transition guide for more details on specifics https://developer.apple.com/library/iOs/documentation/UserExperience/Conceptual/TransitionGuide/Bars.html#//apple_ref/doc/uid/TP40013174-CH8-SW1

Changing the button color of a navigation bar

Is it possible to change the button color without an image in the navigation bar of iOS 6?
I see on other stackoverflow posts that in iOS 5 you needed an image. Is that still true?
Change the color with tint color. The following will give you a button with a red background.
UIBarButtonItem *button = [[UIBarButtonItem alloc] init];
[button setTintColor:[UIColor redColor]];
or if using storyboard/xib there is a tint dropdown.

Resources