Adding Button right of the UiSearchController swift, UIKit - ios

I want to add an button right to the search controller in the navigation, but am not sure how can I implement that... any Ideas?
Am doing it programmatically
I want to replicate this

Use a Horizontal StackView and embed a search bar on the left, and a button on the right. Set the button's imageView to the "gear" image or whatever image you'd like.

Related

How to make multiple right bar button items stack vertically in navigation bar?

How can I add a UIlabel to the area in green? (it will be within the navigation bar)
I was able to add the logo as a button image in rightBarButtonItem, but I can't google a way to add a label to the nav bar in this specific position.
After reading around I'm thinking maybe I have to create a custom view that would contain the logo and a UILabel, arrange them vertically within that view, and then place that view in rightBarButtonItem?
edit: This is a unique problem from other answers here in that I am looking for how to add a UILabel to an area of the NavigationBar that is outside of the "rightBarButtonItem" area. Using rightBarButtonItem or setting a custom view to appear within rightBarButtonItem does not achieve what I am looking for. I want a UILabel to appear in the NavBar on the right side aligned vertically with the "Today" title.
I ended up figuring out that using a custom header within the collectionView is the way to go (rather than trying to place a UILabel into the navigationBar via a custom UIView into the rightBarButtonItem space). This worked for me because I wanted the title and date to disappear upon scrolling anyway. Basically this mimics the "Today" tab in the iOS App Store, and my solution finally achieved what I was looking for.
Finished result:
The 2 posts that helped me set up the collectionView header and attach the labels are here:
How to add UICollectionView Header
Display Section Header UICollectionReusableView
You can follow this code snippet:
let containerView = UIView()
...
let rightBarButton = UIBarButtonItem(customView: containerView)
navigationItem.rightBarButtonItem = rightBarButton

move navigationBar's left and right barButtonItem's vertically upwards

I am trying to move my navigation bar's left and right barButtonItem's upwards vertically without any success. I can manage to move the title view up but using the same method for the barButtonItem's doesn't do anything.
The effect I'm trying to achieve is what is used on the Bookmarks page of safari:
I'm hoping to achieve this without any subclassing of the navigationBar so that I can maintain the translucency.
My approach was to add UIView's to the navigationBar directly in IB for the leftBarButtonItem, Title and rightBarButtonItem. This works fine for the title and I'm able to add the Title and segmentedControl. The problem is when I add the left and right barButtonItem's I am not able to move them vertically above my segmented control. I am using the following code to try to move the barButtonItem's vertically in viewDidLoad():
self.navigationItem.rightBarButtonItem?.setBackgroundVerticalPositionAdjustment(-15, for: UIBarMetrics.defaultPrompt)
self.navigationItem.rightBarButtonItem?.setBackgroundVerticalPositionAdjustment(-15, for: UIBarMetrics.compactPrompt)

Button to imitate UIBarButtonItem

I am using the UIBarButtonItems to trigger special actions but I also want to add another button on the bottom part of the screen with the same dimensions as the ones created in the NavigationBar, how could I do this?
Can I do it in the Interface Builder with some fixed width/height constrains or do I have to do it programatically, if so could you give me an example?
Thank you
The easiest way would be to add a UIToolbar to the bottom of the view. If your view controller is in a UINavigationController, the best way to do this would be to add the bar button items, either in Interface Builder by drag-and-drop or programmatically using setToolbarItems.

iOS/Swift: Dynamically Resize a Toolbar

I'm trying to make an app with a toolbar that can be resized. Basically, the toolbar can alternate between being at the bottom of the view and being at the top. When a button is pressed, it switches from one to the other. The problem is that when it is at the top, I want the size of the toolbar to expand to accommodate the status bar, but I don't know how to do this.
I've seen some solutions for changing the toolbar size but they all seem static and not something that can be changed with the tap of a button. Any suggestions on how to do this? Perhaps a different solution altogether?
You can use a normal UIView and customize it so it looks like a UIToolbar, then just set constraints using AutoLayout and animate the height-constraint.

adding Button on UITtabbar and My button must be higher than TabBar (Objective C)

I'm working on UITabBarController. And now i want to add Button in the middle of UITabBar. The problem is my button must be higher than TabBar. In other words half of my button is out of TabBar. Is it possible? if it is possible, how can i do that? Thanks.
You can cover the UITabBarController with a UIView that has buttons. Use the buttons to programmatically select the correct tab. make the UIView have a clear background and be the height of the tallest button on the bar.

Resources