Change UIWebView Done button color - ios

I am using a UIWebView to display content in an app and would like to change the color of the Done button that is displayed whenever a select control is used.
It is currently displaying as white on gray which is hard to see.

The "Done" button is white because you are probably setting the tintColor to white for all UIBarButtonItems using UIAppearance. That affects the "Done" Button in the picker view which also happens to be a UIBarButtonItem.
So you have to exclude the "Done" button in the picker view from the global white tintColor. I don't know if you only need the white UIBarButtonItems in your navigation bar, but if you do you could do this to only set the tintColor for the bar button items in your navigation bar and leave all other UIBarButtonItems untouched:
UIBarButtonItem.appearanceWhenContainedInInstancesOfClasses([UINavigationBar.self]).tintColor = UIColor.whiteColor()
However this is only available in iOS9 and the old appearanceWhenContainedIn method that works for older iOS versions is not available in Swift.
So, if you are working with Swift and you have to target earlier iOS versions than iOS9 this is probably not working for you. In that case you have to remove the UIAppearance setting for the white tintColor and set the tintColor for the UIBarButtonItems in your navigation bar "manually" without using UIAppearance.

Another possible solution is to just do
UIPickerView.appearance().tintColor = UIColor.blueColor()
put this in your AppDelegate and you are ready to go!

Related

Set background color (not Text Color) of Back button in UINavigationBar IOS

Is there any way to set the background color of back button in NavigationBar like this
There are some post available on SO which shows how to set Tint color. But can anyone let me know if there is way to set Background Color like shown in image above. or i have to set in custom way?
for navigationBar you should setbackgroundImage
navigationController?.navigationBar.setBackgroundImage(UIImage(named: "your image name"),
forBarMetrics: UIBarMetrics.Default)
I tried with Tint color, but I can not make it work properly.
I do that by adding an UIView at the back of the UINavigationBar. In that case it must be properly positioned using Autolayout.
You have to realize, that is not actually back button background.
If you'll take a closer look at navigation bar, you will see back button has a limited width and height. Something like this:
So if you really need to customize your navigation bar, you have 2 variants:
1) set your navigation bar background image, with fixed or adapting back button background
2) implement custom navigation bar, ignoring system UINavigationBar
You can use custom image and set title manually
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:[UIImage imageNamed:#"customImage"]
forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];

Blurred translucent navigation bar in iOS

I'm trying to get this blur-translucent navigation bar effect (The first navigation bar in the image) in my Swift iOS application:
But I can't get this done. I've tried several methods, some of them are below:
setBackgroundImage, shadowImage and translucent attrs in AppDelegate (Getting the NavController from the RootViewController attr)
Those lines in AppDelegate main method:
UINavigationBar.appearance().translucent = true;
UINavigationBar.appearance().barTintColor = UIColor(white: 1, alpha: 0.4)
Changing attributes from UIBuilder
Setting self.automaticallyAdjustsScrollViewInsets = true and self.edgesForExtendedLayout = UIRectEdge.None in viewControllers
But still can't get this to work. I'm running the app on XCode simulators, using iOS 8.1 and 9.0
What I am doing wrong?
The second navigation bar is already translucent and blurred—it just isn't quite as translucent as the first navigation bar. If you open Digital Color Meter and mouse over your screenshot, you can see that the background of the second navigation bar is darker in the area covering the image.
The reason why the first navigation bar is more translucent than the second navigation bar was explained in this question: the screenshot of the first bar was taken from a device running iOS 7.0.2, whereas the screenshot of the second bar was taken from a device running iOS 7.0.4. Apple changed the behaviour of UINavigationBar between those versions of iOS, and again with iOS 7.1.
Apple explains the current translucency mechanism as follows:
A translucent bar mixes its barTintColor with gray before combining it with a system-defined alpha value to produce the final background color that is used to composite the bar with the content it overlies.
The only description of the blur effect appears to be the following:
Navigation bars are translucent by default in iOS 7. Additionally, there is a system blur applied to all navigation bars.
You can change the transparency of the bar by using UIImage.imageWithColor: to make a background image for the bar from a UIColor with an appropriate alpha value, but doing so will remove the blur effect. There is no documented way to alter the "system-defined alpha value" to increase the translucency of the bar without removing the "system blur".
If you want to imitate the old translucency and blurring effects on iOS 8.1 and 9.0, you'll need to make your own subclass of UINavigationBar and insert one or more subviews such as a UIView with a background color that uses an appropriate alpha value (for transparency) and/or a UIVisualEffectView (for the blur effect).
You might be able to find a combined view in one of the answers to this question.
Related: Blurring effect disappeared on iOS 7.1
Add bellow code in didFinishLaunchingWithOptions:
For Objective C
[[UINavigationBar appearance] setTranslucent:NO];
For Swift 3+/iOS 10+
UINavigationBar.appearance().isTranslucent = false
Maybe plist changes can fix your problem.

UIToolbar incorrect colour in iOS7

When I set the bottom UIToolbar to black on the view controller, it appears as a more greyish colour (the same thing happens with other colours--it sort of fades them out). What I assume is happening is that in iOS7 the toolbar seems to adapt the colour of what is beneath it (currently white) which makes for the duller colour.
I've updated the view controller so that the "extended edges" options are turned off but still get this effect. Has anyone else had this issue yet?
UPDATE:
I resolved the issue by setting the background colour of the UIToolbar to black (something I haven't had to do in previous versions of iOS). If anyone can think of a better solution, let me know.
All tool- and navigation bars in iOS 7 have a translucent property.
This causes the effect, where the background shines through in blurred form (just like the control center).
Just set YourToolbar.translucent = NO;.
SET the t*ranslucent property to NO*:-
IN iOS 7 you need to set the barTintColor Property-
UIToolbar *doneToolbar=[[UIToolbar alloc]initWithFrame:CGRectMake(0, 584, 320, 44)];
doneToolbar.translucent=NO;
doneToolbar.barTintColor=[UIColor blackColor];
[self.view addSubview:doneToolbar];
I have used it its working fine...
setting the background color instead of the bar tint worked for me
I set the bar tint to default, the translucent property to NO and the background to the color i wanted and it worked for me.

iOS - SearchDisplayController - SearchBar style

I'm working with SearchDisplayController and want to apply a style or tint to the searchBar.
But I noticed that the SearchDisplayController makes changes to the style of my searchBar.
For example if I use the "Dark Text Color" tint on my searchBar, when running the app, I'll obtain a grey style. But if I remove the searchDisplayController linked to the searchBar, the style in the app is ok.
This image shows the difference between the searchBar in the storyboard and in the app.
Note: If I use the default style, I don't have any problem.
I don't understand what changes the searchDisplayController adds to the searchBar.
Am I missing something or doing something wrong ?
No, you are not doing something wrong. While I'm not sure why it works this way, I can imagine that a somewhat lighter color is chosen in order to distinguish the cancel button (which will have your tint color).
What worked for me was to set the background color to black, no tint color (default), and use the Black Translucent style.
Also remember that when you set a tint color, the style is ignored.
I remember struggling with this for hours, just to get a black search bar.

Change statusbar tint colour

Is there a way to set the status bar tint colour?
I have my navigationbar tint set to brown and when it's on screen it also changes the statusbar to brown, however on views that I hide the navigationbar the statusbar returns to its original colour.
How can I change the statusbar tint colour to persist trough the application?
There is no way in iOS 5. You can just change your bar style.
But if you take a look at new WWDC 2012 Sessions, you may find something interesting)
Session number 216 - Advanced Appearance Customization on iOS
Maybe keep the notification bar there but cover it up? If the notification bar's color influences that of the status bar, then it would lead me to believe that it just has to be in the window (even buried under another view) to change it.
There is no way in iOS 5 or ealier version of ios.
now ios 6 have feature to change status bar tint color or it will set according to navigation bar pattern Image
But u can use Custom Status Bar
What I do in screens that have no navigation bar is to put in a navigation bar at the top but behind the visible interface. The navigation bar is not visible to the user, but it is visible to the system and causes the status bar to adopt its color.
EDIT: Sorry, I see now that someone else had already suggested this. So I'm just confirming that it does work.

Resources