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

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.

Related

Is it possible to add a left bar button item with multiple lines of text

I would like to add a label in the left bar button item with multiple lines of text. the height of the navigation bar will be changed according to the height of the label.
You can add view in left bar button item and add label inside it and give the label constraints as you want to it's superview.
if you want to increase navigation bar height, You can add space in prompt like below image but you can't increase it throw navigationBar.frame, it doesn't work with me.

How to adjust the position of tab bar item 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.

How to remove extra space in UICollectionView when scrolling to top with Status bar gesture?

I have a CollectionView the behavior is normal when I'm scrolling down and If I want to reach to top items using the scroll top top gesture from the status bar I get an extra space.
Extra space in title
Here is a gif showing the behavior:
I don't want that extra space.
I don't know if It's a property in the UICollectionView or in the same NavigationController.
Thanks!
This worked for me the first method setting the top constraint to the superview an not to the safe area "Please take a look at this... i Hope this helps... uicollectionview remove top padding"
Thanks for your help Mr Ahtazaz
you can try this,
first drag and drop a view controller ,
then embed it into navigation controller,
then drag and drop a collection view to the view controller
select the collection view at the bottom there is "add new constraint" click on that and uncheck constraint to margin then give zero to all the four boxes and make sure the red line is highlighted( making sure all the constraints are sets)
click on add constraint now you can rightclick and drag from tabbar to view controller and set it as viewcontrollers

Changing the connecting point of an AutoLayout constraint?

I have the following setup within my app. There is a footer bar that has a number of buttons on, above that there is a UIImageView that currently has the constraints set to 10,10,10,10 for all edges. I have added an image below to show the constraint.
Now what I would like to do is when a button on the footer bar is clicked a new "sub bar" will appear between the footer bar and the UIImageView. My question is how do I adjust the constraint so that the bottom anchor is connected to the new sub bar and not the footer. In a sense it pushes the UIImageView up to make way for the new bar?
I don't want the new bar to go over the UIImageVIew, instead I want to push it up with an animation.
Create that bar between the imageview and the footer and layout it properly then make its height constarint = 0 to be hidden at first, then control darg this constarint as IBOutlet and when you want to show change its constant to say 100 and call:
[self.view layoutIfNeed];
Put it in a UIView animation if you want it animated.

How to place any view below any other view which is getting it's position from code

I've created 4 subviews of white color & a yellow one as you can see in reference image I've shared below.
And I've programmatically changed the position of Tabbar from bottom to top just below to navigation bar as you can see in below image (When it is running in the simulator).
Now since I've constraints for that yellow view in image as follow
It is appearing just below to navigation bar but I want it to be displayed just below the Tabbar.
Since Tabbar is getting its position programmatically & other views (including yellow view) are getting their positions from the storyboard.
And since storyboard UIelements are get settled before any other UIelement which are coming from the program or at least get their position from programmatically.
What could be the best way to achieve what I want.
Please refer my storyboard as well to get more understanding. (Refer Below image)
I also want to fit all 5 subviews in the space between tabbar & bottom of the screen. I want to calculate 1/5th of that space & assign this height to each subview. I'd later reduce few pixels to separate them.
Why not add the height of the tab bar to the yellow view's top position? That way, you'd set the constraint something like:
Fajar.top = top + 44
If the tab bar is always visible, then that should work. But of course, if the tab bar only appears at times, you'd probably have to change that constraint programmatically depending on the change ...

Resources