Navigation bar button images on swift - ios

When trying to customize my navigation bar, it asks me about what images I want to use. I want to customize these images. I use Adobe illustrator to customize various icons. However, when I add the image to the assets and select it, the image is often larger than the navigation bar.

Related

UITabBarController icons not showing up

I have an app that has a UITabBarController with four view controllers embedded.
I've created icons for both normal and selected states and set them via the interface builder. The sizes of the individual icons vary slightly according to the new design guidelines. Also the icons are PDFs. I initially set it's Render As property to Template Image.
The titles of the tab bar icons show up but not the icons.
But they do show up in the interface builder though.
Then I set the Render As to both Original and Default but neither worked.
I'm using Xcode 10.1. What am I missing here?
It seems problem with image you are using. try setting different insets to image and tab bar icon will appear.
i have set some inset for icon and icon appeared in simulator.so you will need proper icon image for asset or would required proper inset for icons.

UIButton is out of navigation bar

I have a custom UI Button (just regular button but with image), within the navigation bar, but when I choose my image it looks like this in designer:
As you can see here, it's over my provider and status labels, and also when I run application it's over the WebView (which is bellow), so definitely out of navigation bar. I tried to find in storyboard some property where I can adjust this but I couldn't find any. I'm using swift and storyboards.
Appreciate any help, iOS newbie :)
Based on your description I think your issue is that you are trying to add a button for navigation. What you need is a NavigationBar with a NavigationItem/BarButtonItem in it. If you look in the object library you will be able to find these.
Just drag them onto your story board. Once there select the button and in the side menu you will be able to select the Image for that Item. Now it is in the navigation bar up top. Let me know if there are still issues. 👱🏼
You have to make sure your 1x image is to the specified size (and then your 2x etc, or just use a PDF at the 1x size.
Icon sizes are here: iOS Human Interface Guidelines: Icon and Image Sizes
I made my pdf 22x22 and added it to .xcassets with scale factor "single vector"

Customize UISearchController in TVOS

i'm working with UISearchController in TVOS application. I'm facing few issues in that.
Basically, this controller is embedded in tabBarController, and i want:
1- Search bar to be placed below the tab bar. Is it possible? I don't want to make my tabBar translucant but to change the frame of search Bar. Is it possible
2- As shown in image, i want the color of alphabets and other keys to be pink (when in focused mode). The default color is black (for focus mode) & grey (for normal mode). How to update that?
Thanks

Getting the right tint for back button

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.

Increase width of tab bar item to fit image

I am doing a simple tab based app, with one 2 tab items and I would like to have an image in
each tab.
The problem is, tabbarcontroller is cropping the images rather than fitting them in. I just have two images, basically text, saying "ABOUT","SETTINGS" and i would like them to take the full width of the tab bar. Something like the attached image. How can i achieve this without the images getting cropped.
Referring to the image "ABOUT" & "SCAN QR" are images.
Thanks
I don't think what you wish to accomplish is achievable by using the standard controls.
I'd recommend using a custom toolbar instead of the tab bar controller.

Resources