iOS 11 - Adding Background image to Navigation bar - ios

I have a view controller with Large Titles and I want to add a background image to it so it takes up the whole navigation bar.
Does anyone know the best way to do this. I've search all over the internet but yet to find any good examples.
Thank you
Goal is to look like this view from starbucks app.

I have checked the image. I think the best way is to add an image view at top. Then on that image view place two buttons with appropriate constraints. Then underneath that image view, add the tableview. Then in the table view cell, at first index you can add the textview, if it is a large text and underneath cells will cover all the things your require with labels in the left and the > image in the right which will lead to a different screen.

I ran into a similar problem just like this and I didn't find any solution over the internet neither. But I do have a simple work around that might be helpful.
What I did is setting the image as navigation bar's background and also add the image to the view in the VC. Make sure the navigation bar has no shadow and its translucent property is set to NO.

Related

In iOS, is there a way to add (overlay) a subview of a UIBarButtonItem image without it moving the buttons already in the bar?

I have my swift 5 app working and I'm now adding a 'tool tips' feature, explaining what each part of the screen does.
The approach I have taken is from an article online - add a subview of grey to dim the background, then to that, add a subview of the item being described again, so it is now highlighted, then also, add a subview of an explainer bubble to explain the item highlighted.
This works fine, so long as the UIView I'm using isn't from a UIBarButtonItem. When it is, the bar buttons underneath the grey screen move around to accomodate what they believe is another bar button being added, which causes everything to miss-align. Other buttons do not have this problem, only UIBarButtons.
Any advice is greatly appreciated. Thanks.
Are you adding the duplicate subview to the bar itself? It'd probably be better to add it to the screen rather than the bar so it doesn't affect the bar's layout. In order to get its frame relative to the view controller so you can display your duplicate in the correct position, you could use:
barButtonItem.convert(barButtonItem.bounds, to: self.view)
Assuming self is a UIViewController.

how can I make three paging views with a custom nav bar in swift

Final Design
I'm trying to make this, three paging views in one with a custom nav bar with icons that will scale when its view is brought up. What is the best way to make the three views, like snapchat's, and how can I relate them to the icons in the nav bar to them? I know that I'll use collection view inside those views with supplementary cells.
I tried to make a Collection View with 3 cells moving horizontally to make the views but I cant relate the icons in the nav bar.
By the way, is it possible to make the navbar triangular like in the GIF?
This is a very broad question but will try to give you pointers for each of the features you are requesting.
To handle the paging views similar to snapchat with relative icons check out SLPagingView. This is a great place for you to get started. You'll need to add in some more code for the scaling but should be trivial.
In order to create a navigation bar similar to what you want you'll need to subclass UINavigationBar and override sizeThatFits and set a backgroundImage. See here here and here.

Best approach for creating this custom UINavigationbar ios

I am creating a UINavigationBar that will expand and contract in various states. The top image is when it is in a contracted state with a transparent background. The lower image represents when it has expanded with a background and search bar. As the user scrolls down the nav bar background would animate in and expose the search field.
Can someone suggest the best way to build this?
So far I've explored subclassing the UINavigationBar, but I've been having a really tough time with the placement of the items within the nav bar or hooking that view up to a xib. I've also see examples where the extended content is just a UIview anchored to the top of the view controller top margin, but then I'm splitting the appearance of my nav into two views which will make the animation problematic.
According to the answer to UISegmentedControl below UINavigationbar in iOS 7 it can be accomplished using a UIToolBar and some delegate methods.
You might have to tweak it a little bit however, to fit the search bar that you want to include.

Creating custom implementation of navigation bar

I wish to create a view similar in behavior to the UINavigationBar.
I cannot simply customize the bar as I want the space to be taller and I want to have several other subviews on it other than just UIBarButtonItems. So, I want to be able to create a similar implementation including the floating/translucency effect.
I good example of this is the address bar in Safari in iOS 7. The UITextField on the bar is something that cannot be added on the default UINavigationBar. Nevertheless, the Safari bar still has the transparency.
I do not want it to shrink like it does in Safari when scrolling down, I simply want it to remain just like a UINavigationBar would. I was thinking about adding a subview to the root UIScrollView, but this would scroll along with everything. I want this to remain at the top, but I want other elements to be able to scroll.
How would I go about implementing this?
If you are confident that you can't to this with the default UINavigationBar, you could shrink (from the top) the UIScrollView with whatever the size the custom UINavigationBar is and then add the navbar as a subview to the root view at (0,0) coordinates. It will be independent from the scroll view.
On the other hand, if you need this to be persistent through the application and use it in all of the screens, it will be wise to make some changes starting for the AppDelegate, but that's for another question.
For the iOS 7 transparent-style part, look here: FXBlurView. Best of luck!

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