I need to animate left bar button moving to right side of menu list view in slide bar menu view controller
How can i animate this in swift3.
UIView.animate(withDuration: 0.3, animations: { (Void)
}, completion:nil)
Simple Answer:
You can use a Cloaking in your code
1.create a BarButton on the window the appearance is the same as your left bar button on your viewController, and hide the left bar button on your viewController.
2.animate the BarButton which on the window to your ' right side of menu list view in slide bar menu view controller'.
3.on your slide bar menu view controller create a BarButton the same as your barButton, and remove the BarButton which on the window.
so it will realize your idea.
Related
I have 2 UIViewControllers. VC1 i embedded into a Navigation controller. I clicked and dragged a UIBarButtonItem to the top right of this VC. I set this button to segue to VC2.
When I try to click and drag a UIBarButton Itemt into VC2 it will not stay in the top right corner. i snaps to the bottom left corner. I know I can do it programatically using self.navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(handleDone)) ButI want to know why I can't do it in storyboard? as I prefer using it.
It's not a trivial gesture, but you can do it. The problem is that you are dropping the bar button item in the wrong place. Make sure you are hovering the bar button item over the right side of the navigation bar until it "lights up", as shown below:
I have implemented the slide menu it has a close button but the close button goes under the navigation bar. How it brings it above the navigation bar and slide as menu slider.
Here is how I want the close button.
Try this :
let window = UIApplication.sharedApplication().keyWindow!
window.addSubview(menuView)
window?.bringSubview(toFront: menuView)
How can I hide my left bar button item?
In my storyboard I dragged a Navigation Bar onto my View Controller, then a Bar Button Item. Under certain conditions I want to hide the Bar Button Item.
None of this works:
override func viewDidLoad() {
self.navigationItem.leftBarButtonItem = nil
self.navigationItem.leftBarButtonItems = []
self.navigationItem.setLeftBarButtonItems([], animated: true)
}
I dragged a Navigation Bar onto my View Controller
Well, don't! There is a big difference between a navigation controller interface, where you set the navigationItem, and a loosey-goosey navigation bar just sitting there in the interface, which is what you have.
Embed your view controller in a UINavigationController and do things the right way. Then setting your navigationItem and its properties will work as expected.
You can't access to self.navigationItem.leftBarButtonItem because you manually drag navigationBar from storyboard. I would suggest to do the following instead:
add an IBOutlet of BarButtonItem (eg: barButton) that you created in storyboard
barButton.title = ""
barButton.isEnable = false
This will hide your BarButtonItem, and you can simply show it back later.
I am using Evgeny Nazarov's Swift Side Menu for my iOS app and was wondering if anyone has used this same library and able to have the same Navigation Bar for every View Controller that is called from the menu.
I put a BarButtonItem that toggles the sliding menu on my Root View Controller. My problem is that only my Root View Controller shows this Toggle Button. But I would like to have that same Navigation Bar with the Toggle button on every View Controller that is accessible when clicking an option on the sliding menu.
Has anyone had an experience achieving this? Thanks!
UPDATE 1
This is what happens when I added a NavigationBar and BarButtonItem to the other ViewControllers that aren't the RootViewController. The new Navigation Bar ends up under the existing Navigation Bar from the Navigation Controller.
The screen on the left is the Root View Controller and the one on the right is the View Controller when I select the second item on the menu.
UPDATE 2: SOLVED
override func viewDidLoad() {
super.viewDidLoad()
let menuItem = UIBarButtonItem(image: UIImage(named: "icon_menu"), style: .Plain, target: self, action: "menuBarButtonItemClicked")
menuItem.tintColor = UIColor.whiteColor()
self.navigationItem.leftBarButtonItem = menuItem
}
func menuBarButtonItemClicked() {
toggleSideMenuView()
}
You need to put a UIBarButtonItem on the navigation bar in every view controller, not in the root view controller.
I too have used the same design for my app and I solved it this way:
View every sect "Show the Attribute Inspector -> Top bar" the voice "Translucent Navigation Bar", then drag the "Navigation Item" and then "Bar Button Item" in the position you want. Of course every button should have its code or references to the ViewController.
Let me know if you have solved.
I am using JASidePanels in iOS and trying to get the menu button to show on the right instead of the left (center panel is a UINavigationController so the left menu button gets replaced with the back button text) but I cannot seem to get the right button to show regardless of what I try.
I tried setting only a right panel (no left panel). Is there a way within JASidePanels to move the menu button from the left side of the navigation bar to the right side?
thanks
Add a new bar button to the navigation bar within your viewDidLoad method:
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:#"Right"
style:UIBarButtonItemStylePlain
target:self
action:#selector(toggleRightPanel)];
and method to be called by right bar button:
- (void)toggleRightPanel {
[[self.parentViewController valueForKey:#"sidePanelController"] performSelector:#selector(toggleRightPanel:)];
}