How to adjust the position of tab bar item iOS? - ios

I want to create a custom tabBar like this
Now I just can create a tabBar as below, I want the 4 tab bar Items (the add sign is a button) to be centered and don't cover the button, so the cart icon should move to the left a little bit, and the mall icon should move to the right. But I don't know how to adjust the position of tab bar item, neither using storyBoard or in a programmatic way.
Thank you for your help.

You should try adjusting the insets for the individual icons. You can do this in the storyboard.
Check this post:
Moving UITabBarItem Image down?

Please modify Item Position in Attributes Inspector in Storyboard.
Select Item position as "Centered".
Choose Custom for Width and Spacing.
Play with the numbers for Width and Spacing and set it was you wish.

Related

How can we set different height for particular UITabBarItem's image in UITabBar?

I have an image for middle UITabBarItem which should start from the bottom and align with existing UITabBar. How can I change the height of UITabBarItem for middle item?
To achieve this you need to use your custom TabBarView. It is a simple view, that pinned to the bottom. Design like you want and that's all! This is the best way without issues with working default TabBar.
every "not default looking" tab bar - it is custom

Bar Button Item is not Showing

I am trying to create a bottom toolbar. So I dragged I Bar Button Item to the View Controller and it was automatically position at the bottom, see image below:
But when I run the app, it doesn't show the bar at the bottom.
I already added:self.navigationController?.navigationBarHidden = false
I think it's just only a constraints problem.
First of all check your Document Outline near to the left of your table, to see the position (toolbar is just below table):
Add your constraints and pay attention to all options as shown in the picture:
Then, take a look to the size inspector, for the table view:
And for the toolbar:
This configuration working both in portrait/landscape mode.
Drag UIToolbar controller directly instead of only UIBarbutton item.
self.navigationController?.navigationBar.hidden=false
Have you set constraints of UIToolbar? I just guess it can be one of the reasons why you cannot see your barbuttoitem.
The navigation bar and the toolbar are two different things and the toolbar is hidden by default. Try setting the toolbar hidden attribute to false.
Sometimes bar button item and bar button do not show when we present our screen. On screen we can then not see bar button item and bar button. So we need to push our screen if we want bar button item and rightBarButtonItem.

iOS storyboards - UINavigationBar not appearing when I add it

I added a UINavigationBar to a detail controller scene, but when I run my app the UINavigationBar does not appear. Why is it doing this ? I have the custom class set to the controller I want it too, but its not appearing, here is a screenshot.
but when I run this app, I dont see the "Title" bar or anything.
To add constraints select your navigation bar and click in the icon as in the picture.
uncheck "constrain to margins" as you want the navigation bar to snap in the boards of the screen, select the up and left red dots lines and add the value 0 to the drop boxes, meaning 0 pixels from the left and top of the screen.
Select Update frames and click in add constraints.
I can see in your screenshot you have other screen with problems (red icon next to the view controller) you should also fix that, click in the icon for more details about the error/warning
I am not sure if I understand what you are trying to do, but try this,
Select the detail view and go to the xCode menu and select editor->Embed in-> Navigation Controller.
I hope it helps
Add constraints to your navigation bar. However, IcaroNZ suggested the best way for navigation

UIWebView inside TabBarController causes content to go behind tab bar

I have a web view inside a tab bar controller. The problem is when using the web view, the content goes behind the tab bar and I cannot scroll to the bottom of the page. How do I resolve this?
Here is how everything is setup in Xcode
If you are using AutoLayout set the constraints of the UIWebView so that it is attached to all the sides.
Edit: Instructions
Select the UIWebView
Select the icon shown in the picture below
Unselect the Checkbox for "Constrain to Margins" because we want to constrain to neighbor
Set the numbers around the center square to 0's
Click the icons that are between the middle square and the numbers you just changed
Click Add Constraints

How to achieve uneven spacing between the items in tab bar?

In my application I want to set the tab bar items at uneven positions inside the UITabbar (meaning the space between 1st and 2nd is not equal to the 2nd and 3rd and so on)
I know there is no such options as the item don't have a frame property. so is that possible to achieve this by some other ways like
self.tabBarController.tabBar addSubview:buttonItem
Or is it Possible to reposition the items in the desired location inside tab bar?
In your storyboard, you can drag and drop a "Fixed/Flexible space bar button item" into your toolbar. This will serve as a separator between buttons. Also, Drag and drop an outlet connection to the controller if you want to control its width programmatically. You can also adjust the spacing through the inspector (look for the width property). For example if your Fixed space bar button item's outlet name is spacer, you can set the width of the spacer as follows:
self.spacer.width = 50; (or whatever value)
Hope this helps.

Resources