Hi IOS programmer,
I program an app that have slide menu by using continar and leading constant. The problem is when I click the button to slide the menu the menu didn't display but when I click again the menu displaied!! This code from https://github.com/Kilo-Loco/SideMenu/blob/master/Side%20Menu/MainVC.swift Hope anyone help me please. The following code display my problem.
class ViewControllerContainer: UIViewController {
@IBOutlet weak var sideMenuConstraint1: NSLayoutConstraint!
var sideMenuOpen = false
override func viewDidLoad() {
super.viewDidLoad()
NotificationCenter.default.addObserver(self,
selector: #selector(toggleSideMenu),
name: NSNotification.Name("ToggleSideMenu"),
object: nil) }
@objc func toggleSideMenu(_ sender: Any) {
if sideMenuOpen {
sideMenuConstraint1.constant = 236
sideMenuOpen = false
} else {
sideMenuConstraint1.constant = 0
sideMenuOpen = true
}
UIView.animate(withDuration: 0.3) {
self.view.layoutIfNeeded()
}
}