How to Create Your Own Slide-Out Panel Navigation | raywenderlich.com

This easy tutorial will help you add the popular slide-out navigation panels to your apps using Swift 4, Xcode 10 and iOS 12.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/1005187-how-to-create-your-own-slide-out-panel-navigation

ok so I’m here because I used your sprite kit tutorial and I have a question about if I wanted to add a label to it that counts the score what would I do this has been driving me nuts for the past couple of days

@yeeter Please check out the documentation for the SKLabelNode class when you get a chance:

https://developer.apple.com/documentation/spritekit/sklabelnode

I hope it helps!

This is very useful. But my app crashes when I try to change the data and reload the collectionview. Any tips? Thanks!

So I added cache.removeAll() on prepare() and also invalidated the layout and it worked well on actual device.

@cat_dev Glad you sorted it out! Cheers! :]

Awsome tutorial. Thanks

Hey!

First of all, thank for your very nice tutorial !

I think there is something missing and could be nice to explain how to manage it.

If the name of the text is very long, the text will not be ellipsize, because the width of the sidepanel equals the width of the screen, so the half of the text will be hidden by the central view.

What is the purpose of underscore “in” keyword here:

func animateRightPanel(shouldExpand: Bool) {
  if shouldExpand {
    currentState = .rightPanelExpanded
    animateCenterPanelXPosition(
      targetPosition: -centerNavigationController.view.frame.width 
        + centerPanelExpandedOffset)
  } else {
    animateCenterPanelXPosition(targetPosition: 0) { _ in
      self.currentState = .bothCollapsed
      self.rightViewController?.view.removeFromSuperview()
      self.rightViewController = nil
    }
  }
}

I noticed that if I comment out the { _ in and the closing }, the code will still work.

Thanks!

@wviper3 Can you please help with this when you get a chance? Thank you - much appreciated! :]

“Don’t worry about the compiler error on the second line, you’ll take care of that shortly.”

This should really be shown before the code fragment so that people don’t spend 10 minutes trying to fix an error one assumes one has written in the code. Such was my experience, at least.

Even better, you could put the extension with the CenterViewControllerDelegate in first to avoid the error altogether.

Hi,

I am trying to implement this in an App but it’s not working. Comparing my app to the master the issue is the AppDelegate.

Orignal is:
window = UIWindow(frame: UIScreen.main.bounds)

let containerViewController = ContainerViewController()

window!.rootViewController = containerViewController
window!.makeKeyAndVisible()

In my app I have a login vc which is the root vc, but when i try to change this and login, the slide out button doesnt do anything.

Does anyone know how to solve this?

Thanks

@ramw Do you still have issues with this?

func showShadowForCenterViewController(_ shouldShowShadow: Bool)

The shadow appears on the centerNavigationController for me on ios12 simulators but not on ios13. I’m digging through all kinds of sources and can’t not find an answer as to why? I’ve tried setting background colors, changing zPosition, setting border.

Anyone have any ideas?

Try to write in viewDidLoad after centerNavigationController initialization:
centerNavigationController.view.layer.masksToBounds = false

1 Like

Thank you, that worked great. Documentation says masksToBounds is false by default. Any idea why we have to specify for iOS 13?

@wviper3 Do you have any feedback about this? Thank you - much appreciated! :]

Question: why do we add and remove side panels? Why not just create them once and then keep them? Is it because this way, we are saving memory?

@wviper3 Can you please help with this when you get a chance? Thank you - much appreciated! :]

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!