Why does my app look like this in the multitasking drawer? - ios

In my AppDelegate I've customized the colors of the UINavigationBar, but when I double tap the home button to open the multitasking drawer, my app preview looks like this:
When in reality its supposed to look like this:
(Just ignore the different content in app.)
This is the code I use for changeing colors and fonts:
// set navigation bar colors
UINavigationBar *navigationBar = [UINavigationBar appearance];
navigationBar.barTintColor = redColor;
navigationBar.tintColor = [UIColor whiteColor];
navigationBar.titleTextAttributes = #{
NSForegroundColorAttributeName: [UIColor whiteColor],
NSFontAttributeName: [UIFont fontWithName:#"SOLIDARITET" size:26.0]
};

Found the solution. I selected my Storyboard file, and set the background color in the Attributes Inspector from currentColor to whiteColor.

Related

UITabBar.appearance().tintColor not changing icon colors

I'm calling UITabBar.appearance().tintColor = Constants.MAIN_COLOR in my didFinishLaunchingWithOptions but no matter what I change that color value too, my tab bar icons always appears the color of the actual image when selected. Any idea why my tab bar icons are not changing to the color defined in the code above? I made sure I wasn't calling the UITabBar.appearance() anywhere else in my project as well by doing a search.
Are you using custom icons? Then try these methods:
[[UITabBar appearance] setSelectedImageTintColor:[UIColor whiteColor]];
and for text:
[[UITabBarItem appearance] setTitleTextAttributes: #{ UITextAttributeTextColor: [UIColor someColor]}
forState: UIControlStateHighlighted];

How to set the UISearchBar cancel button highlight color

I have a UISearchBar that is added to my view controller in a xib file.
I have the following properties set through Interface Builder:
barStyle = UIBarStyleDefault
searchBarStyle = UISearchBarStyleMinimal
translucent = YES
barTintColor = Clear Color
In code I'm styling the bar with this code, to make the text color white:
[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor whiteColor]];
Also in my app delegate didFinishLoading method I have:
self.window.tintColor = [UIColor whiteColor];
My cancel button in the UISearchBar is a light grey. When I select it it highlights blue, which is jarring as it doesn't fit with any of the other visual elements in the screen. How can I change the button to highlight to a different color? Alternatively I would be fine if the cancel button was white and highlighted to a grey, like my navigation bar buttons do, but I don't know how to change the button color.
I'm targeting iOS7, using Xcode 5.
This answer seems appropriate, but it is having no effect for me https://stackoverflow.com/a/15791136/472344
Try this in Appdelegate in didFinishLaunchingWithOptions
[[UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],UITextAttributeTextColor,[NSValue valueWithUIOffset:UIOffsetMake(0, 1)],UITextAttributeTextShadowOffset,nil] forState:UIControlStateNormal];
Try to set tintColor of the Search Bar. it work for me with target 8.0 xcode 5.
self.searchBar.tintColor = [UIColor blackColor];

change navigationbar button colors for ios7

I am trying to find out how to change the text and arrow color of the UINavigationBar buttons.
I know how to change the titleTextAttributes but cannot find out how to do it to the buttons.
For example this is how I change the titleTextAttributes inside my AppDelegate
self.navigationController.navigationBar.titleTextAttributes = #{NSForegroundColorAttributeName : [UIColor redColor]};
I have looked through the UINavigationBar docs and cannot find any button attributes so not sure what to do here.
to change the text color and the color of the arrow in the navigation bar you can use this code (iOS 7):
self.navigationController.navigationBar.tintColor = [UIColor redColor];
this code will also change the color of the buttons
You can globally change it as easy as this

Changing the Tint Color of UIBarButtonItem

I have a project using Storyboards and whenever I push a view controller with a segue, the dynamically created bar button item is always blue.
It's driving me nuts. Because this object is created dynamically, I cannot set its color in IB (like I have done with previous bar button items).
Among the solutions I have tried are:
Set it in the receiver's viewDidLoad
Set it in the receiver's viewDidAppear
self.navigationItem.backBarButtonItem.tintColor = [UIColor whiteColor];
When I saw that didn't quite work, I tried setting the leftBarButtonItem instead:
self.navigationItem.leftBarButtonItem.tintColor = [UIColor whiteColor];
I have tried the following code (which I got from other SO answers) in my app's delegate, when the new view gets called, and before pushing the new view:
[[UIBarButtonItem appearance] setTintColor:[UIColor whiteColor]];
All the google answers I have found recommend to use the code above, but it's not working at all for me. Maybe there are some changes in iOS 7's appearance API? No matter how or where I try to set "Categorías" to white, it's always the default blue.
In iOS 7, to set the color of all barButtonItems in your app, set the tintColor property on the application's window in the AppDelegate.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window.tintColor = [UIColor whiteColor];
return YES;
}
More detailed info in Apple's iOS 7 UI Transition Guide (Specifically under the 'Using Tint Color` section).
***OR***
Based on some of the comments, you can also achieve this with the UINavigationBar appearance proxy. This will affect the tintColor of only UIBarButtonItems, as opposed to setting the tintColor on the window and affecting all subviews of that window.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
if([UINavigationBar conformsToProtocol:#protocol(UIAppearanceContainer)]) {
[UINavigationBar appearance].tintColor = [UIColor whiteColor];
}
return YES;
}
I think you are looking for a property of your UINavigationBar. Try setting self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
See "Appearance of Navigation Bars" section: https://developer.apple.com/library/ios/documentation/userexperience/conceptual/UIKitUICatalog/UINavigationBar.html#//apple_ref/doc/uid/TP40012857-UINavigationBar-SW1
In Swift 3.0
let navigationBarAppearnce = UINavigationBar.appearance()
A navigation bar’s tintColor affects the color of the back indicator image, button titles, and button images.
navigationBarAppearnce.barTintColor = UIColor(red: 0.180, green: 0.459, blue: 0.733, alpha: 1.00)
The barTintColor property affects the color of the bar itself
navigationBarAppearnce.tintColor = UIColor.white
Final Code
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let navigationBarAppearnce = UINavigationBar.appearance()
navigationBarAppearnce.barTintColor = UIColor(red: 0.180, green: 0.459, blue: 0.733, alpha: 1.00)
navigationBarAppearnce.tintColor = UIColor.white
navigationBarAppearnce.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.white]
//Change status bar color
UIApplication.shared.statusBarStyle = .lightContent
return true
}
Swift 5
barButtonItem.setTitleTextAttributes([NSAttributedString.Key.foregroundColor : UIColor.white], for: .normal)
To change the color of a specific item (e.g. a button) in your nav bar:
In Objective-C
myButton.tintColor = [UIColor redColor];
In iOS 8 if you changed UIView tint color for some purpose, for example for branding UIAlertView, tint color for UIBarButtonItem in UIToolBar also changed that way. To fix this, just write this code
[UIView appearance].tintColor = SOME_COLOR;
[UIView appearanceWhenContainedIn:[UIToolbar class], nil].tintColor = BLACK_COLOR;
For UIBarButtonItem tint color in UINavigationBar use standard method
[UINavigationBar appearance].tintColor = BLACK_COLOR;
UITabBar.appearance().tintColor = UIColor.yellowColor()
This worked for me
AddBarButtonItem.setTitleTextAttributes([NSAttributedString.Key.foregroundColor : UIColor.white], for: .normal)

customize UIBarButtonItem in Navigation Bar

I was trying to customizing the UIBarButtonItem in Navigation Bar
I found that there is a property in UIBarButtonItem : "tintColor" , and I set it like this
self.navigationItem.leftBarButtonItem.tintColor = [UIColor redColor];
It works well, but if I try this :
self.navigationItem.leftBarButtonItem.tintColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"imageName"]];
1. It doesn't work as expect , however , the leftBarButtonItem shows a black appearance ,why ?
If I try a clearColor :
self.navigationItem.leftBarButtonItem.tintColor = [UIColor clearColor];
2. The leftBarButtonItem shows a black appearance still, why ?
3. I want to customize it with a pattern image like above , how can I do that ?
Thank you
You can check this sample code for customizing navigation bar and back button
https://github.com/boctor/idev-recipes/tree/master/CustomBackButton

Resources