I am trying to achieve this look for my back button:
But no matter where I sample the shade of green in photoshop, it never comes out correct. For example:
Any suggestions on how I can achieve the exact same look?
The tint color is exactly that—a tint. iOS uses that color as a base to create a nice-looking button in the style of normal navigation bars.
If you want to control your button's appearance more precisely than tinting allows, your best bet is to create a set of images and use -setBackButtonBackgroundImage:forState:barMetrics: to use them. If you want this look for all bar button items in your app, use that method on +[UIBarButtonItem appearance], rather than a specific bar button item.
In order to produce the BackBarButtonItem's gradient, iOS does the following:
Applies the tint color that you specify
Applies a transparent overlay on top of the back button
Here are the retina-display overlays it uses for iPhone (these were obtained using UIKit-Artwork-Extractor):
Default Back Button Overlay
Pressed Back Button Overalay
Unfortunately, there is no way to tell iOS / UIBarButtonItem NOT to render these overlays on the back button (thereby, this gives the default navigation bar and buttons a pretty consistent look across all apps).
If you don't want to have this overlay applied (it will darken the button in both states), you have to create your own back button images - for the default and pressed states, portrait and landscape orientations, and retina and non-retina displays (8 total images).
As Brent Royal-Gordon mentions in his answer, you can apply these images using the appearance proxy for UIBarButtonItem to have them used throughout the app. In example, you'd set the default background image state like this for portrait orientation:
UIImage *defaultBackImage = [UIImage imageNamed:#"My-Default-Back-Button"];
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:defaultBackImage forState: UIControlStateNormal barMetrics:UIBarMetricsDefault];
It looks like the button is adding another semi-transparent gray layer over the button. I can't check right now but I would look for settings to disable the semi-transparent layer effect or try different button style/states.
Related
I have an iOS app that uses a custom back chevron for the back button in navigation bars with custom background colors and shadows and such. I'd like to set the color of that back indicator image to something besides the default blue. How do I do that with the new UINavigationBarAppearance APIs?
I have tried:
Setting the back indicator image to a template image of my shape - this works, but doesn't affect the color.
Setting titleTextAttributes on the normal variant of the buttonAppearance, specifying NSForegroundColorAttributeName
Setting titleTextAttributes on all variants of the backButtonAppearance, specifying NSForegroundColorAttributeName and NSBackgroundColorAttributeName
Setting tintColor on the navigation bar directly - this affects the back indicator during animation of a new navigation item, but at the end of the animation it goes back to blue.
The tintColor works for me. The attached screencast shows (using slow animations) that having set the tint color to black, it stays black, both pushing and popping:
Is there any away to remove tab bar blurred effect
I set background image and it looks like the first picture.
If I make it transparent, you can see the table through it like the second picture.
I want to make it like the third picture
You can make it transparent using
the barTintColor property.
nameOfTabBar.barTintColor = .clear
This property is incharge of the tint color to apply to the tab bar background.
You can find more information on https://developer.apple.com/documentation/uikit/uitabbar
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];
How do I achieve the "Find My Friends" button look using iOS 5? it is as if the buttons are stamped into the leather.
I like the look of the Find My Friends app, it looks like leather and the buttons look like they are stamped into the leather. So, I was wondering how do I achieve this stamped in effect. I know how to set the background image in iOS 5 on a UINavigationBar, and I can set the tint color of a UIBarButton.
But, how do I get the image on the UINavigationBar to bleed through to the UIBarButton?
Everything I've tried leads to a black button and no bleeding of the background image.
I was thinking that there must be a way to set the transparency of the UIBarButton.
Does anyone know if this possible in iOS 5?
Or, do I need to do this?
Create a custom button image that is in the shape of the button image : rounded corners , 3D button effect and a transparent color in the middle.
This way the leather will show through where it is transparent in the middle of the button.
Thanks in advance! Brian.
Get your artist to draw the stamped button for you. The system is not going to offer any help.
I'm pretty sure you'll need to go with building a custom button image that has a translucent background colour for the leather to show through.
As you've mentioned, you can set the tintColor property on UIBarButtonItem, but this doesn't seem to respect the alpha of the colour you set. The image seems the best way to go.
I'm trying to put a UIBarButtonItem with a custom image on a UINavigationBar. When I do however, the image doesn't look right. I want the button on the navigation bar to look like the one below it.
(This is a screenshot from the simulator, by the way, not Interface Builder)
I created the custom UIBarButtonItem by creating a UIButton, using the cog-wheel image as a background, and then simply dragging it to the the right bar button item place in Interface Builder. Seeing as creating a UIBarButtonItem programmatically with the aforementioned UIButton as its 'custom view' (-initWithCustomView) has the same result, I believe this is what is happening as well.
What I don't understand is why the button image lost its nice edges and color gradient when I added it to the navigation bar wrapped in a bar button item. Can anyone tell me?
Thanks in advance.
The image hasn't changed. It is the same. Its just that when put on different backgrounds, it is showing differently. You should consider increasing the contrast.