Creating custom implementation of navigation bar - ios

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!

Related

Scrolling effect in ViewController

How can I achieve when the user scrolls in the ViewController down to make the highlighted text show up in NavigationBar and when the user scrolls back up to make it disappear again? Similar to Apple's one in Settings app in Apple advertising (https://imgur.com/0FeFJ3s)
Edit:
Looking at the image you posted, this seems to be the default transition a large style navigation bar gives you. The only tweak that's been done is centering the title text.
Original answer:
The text in the navigation bar follows the .title property of your view controller. However, setting the title is not animated. Depending on your use case, that may or may not be enough.
If you want to do things a bit more fancy, you have some control over the .navigationItem.titleView in a view controller. This way you can use a custom view in the navigation bar. Using this, and a bit of fancy programming, you can animate things there.
Last, you can read the scroll position of a UITableView or a UIScrollView by implementing the scroll view's delegate's scrollViewDidScroll method. How you know where the labels that are interesting are depends on the content of your scrollView, so I can't answer that for you.

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.

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.

Take UISearchDisplayController full screen with UIView acting as UINavigationBar

I am having a hard time adding a UISearchDisplayController to my app. The situation is this: The primary navigation in the app takes place by scrolling between UITableViewControllers whose table views are all subviews of a UIScrollView. Each of these has a UISearchDisplayController for searching the contents within each UITableView.
I also have a UIView outside of the UIScrollView which takes up the entire width of the screen and 85 pixels of the height, located at the very top of the interface. This acts as a kind of UINavigationBar, but due to the very custom nature of this element, I have made it a subclass of UIView.
My problem is that when you activate the UISearchBar, I want the "navigation bar" to move off the screen and the UISearchBar to take its place (like in the native Mail app where tapping the search field hides the navigation bar). It seems to me like I not only have to manually hide the "navigation bar" but also expand the size of the UIScrollView and all of its nested UITableViews in order to achieve this.
I am still a novice, so I am completely puzzled as to how to do this. Is there a simple solution or do I have to do this all manually and/or restructure my code in order to create the desired effect?

Simple Horizontal Button Bar for iOS

I have a requirement for a very simple Button Bar.
It should take up the width of the screen.
It should allow at least 3
buttons.
The buttons should be of equal width and together take up
the whole width of the bar.
Each button should be tappable, but not
have a selected state.
The bar will be overlaid on a MapView and positioned directly above a TabBar.
Tapping a button will launch a Modal ViewController.
I thought about using a UITabBar and not allowing its tabs to become selected, but the HIG is pretty clear that this is not correct usage and UIToolBar doesn't allow the button widths to be set.
This seems like a very simple requirement but I can't see an obvious solution. Is there something I'm missing? Can anyone suggest a solution?
What's wrong with just creating a simple view that draws an appropriate gradient, and then adding three buttons of the appropriate size?
If you're feeling ambitious, or if this is something that you're likely to use more than once, you could even have the view create the three buttons. Call it ThreeButtonBar or something. Give it a constant height and adjust the width to match that of its superview so that you can use it in portrait or landscape orientation.

Resources