I have a UINavigatorBar and dropped a button to the left top corner in the Interface Builder.
Simple question:
The Button is round, how I can set the button to a "back-style" button?
(I mean, that the left side of the button is not round, it should be a arrow).
I just put together a simple UIViewController subclass that adds a customizable back button that allows you to change text colors. It basically adds some willAppear/willDisappear logic to animate the back button the way the UINavigationController does while using the leftBarButtonItem property. You'd just have to swap out the back-button PNG and change your colors in a subclass.
https://github.com/typeoneerror/BBCustomBackButtonViewController
If you want the back button to go back to the last view in the hierarchy, just leave the button off of the top left corner, and it should show up automatically.
Otherwise, you may need to subclass UIBarButtonItem.
I think if you want to do this with a UINavigationBar that does not work in conjunction with a UINavigationController you need to create a custom view for the button that is shaped like the back button.
Related
I want to move the navigation controller bar to the bottom of the view controller. How can i get this done ?
I tried :
self.navigationController!.navigationBar.frame = CGRectMake(
0,
UIScreen.mainScreen().bounds.height - 50,
UIScreen.mainScreen().bounds.width,
50)
This is moving to the bottom but hiding all other controller objects and also back button is not woking.
Sujay U N,
You should not try to move the UINavigationBar provided by the embeded UINavigationController to the bottom of the screen. Trying that will obvisoulsy move all the view's below it causing all the controller objects to hide.
Workaround
Approach 1:
Consider using ToolBar :)
Toolbar is designed to be placed at the bottom of the screen. If you are using xib or storyboard you can pick toolbar from components library and place it on your ViewController's bottom and then apply autoresizing masks or constraints properly :)
Now in order to show the back button make use of UIBarButtonItems. Change the style to custom and provide it arrow image or provide default style as done.
Though now you are all set to go :) You will notice UINavigationBar at the top of your view controller. In order to get rid of it,
select your ViewController, select its TopBar property set it to none :)
Approach 2
Use UINavigationBar.
Specific about using Navigation bar and dont want to use toolbar, well you can do the same thing with UINavigationBar as well.
Drag the UINavigationBar from components library place it at the bottom of the screen. Drag the UIBarButtonItem drop it as leftBarButtonItem, change the barButtonItem image to your back image. ( Same process as UIToolBar just use UINavigationBar instead)
Understand this is not same as the navigation bar provided by the embeded NavigationController. So get rid of NavigationBar at the top of your ViewController same as I explained above here as well
Finally,
In both the cases, draw an IBoutlet from barbutton item and handle poping the viewController programmatically.
Happy coding :)
I currently have a view with a navigation controller and two menu bar items, the left one causes a slide out panel to appear using SWReveal. What I want to do is add a navigation controller to the slide out panel, but make it so the right button doesn't get cut off by the upper view.
I want a button just to the left of where the hamburger button on the upper view is. I'd like to do this in Swift, if there's no way to do it in the storyboard.
I found the solution after looking at this post. Just go into SWRevealViewController.m, scroll down to the _initDefaultProperties block, and change the value of _rearViewRevealOverdraw from 60.0f to 0.0f.
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.
The navigation bar in iBooks is exactly what I'm looking to implement. That is, a transparent top bar with the return button in the top left and some buttons in the top right to invoke actions.
However, I'm not exactly sure how this effect would be accomplished. The transparency especially. Can anyone point me in the right direction of how I might accomplish this?
Use a custom UIView subclass. Just add some buttons and set the alpha of the view. Use the controller's UINavigationController to push or pop controllers.The navigationbar should be hidden.
I would not use a navigationControllerBar, I would use a simple UIToolbar to do this. Especially you can have only two button on the navigationControllerBar (left and right button) unlike on a UIToolbar.
The UIToolbar is absolutely customizable, you can set the opacity to 0% and the opaque to NO, after it can be transparent....
With UIView or UIToolbar the alpha is fully customisable. You should subclass one of those two (UIView or UIToolbar), add your buttons and then go from there.
I'd like to create a function that essentially translucently greys out the screen. For example, if you hold the off button on an iPhone/iPad the screen greys out and gives you the option to turn off the device. I'd like to implement the same type of thing. If a function is called, grey out a screen and include a button on the screen, and if the button is pressed it goes back to normal.
My guess is that you would create some sort of new view and place it on top of the current view, but I am not sure how to do that.
Create a UIView subclass that has a background color of [UIColor blackColor] and set the alpha value for that view to 0.5. When you add it as a subview over whatever you view you want to obscure, it should look roughly like the "Power Down" screen tint.
Add a button to that (at full alpha) and it'll look super slick.