Assuming only left-menu part is left and menu is sliding on button click.
Follow below steps :
- Take new
UIViewController
in your storyboard
.
Do this
a) Add new UIView
with size of UIViewController
(says viewBG).
b) Now goto property and decrease the viewBG
opacity according to you, Don't play with alpha value.
c) Take one more view of your left menu (says viewMenu).
Add Your menuVC
as a child VC of your MainVC
.
- Now use below line code when you wanted to show menu.
menuVC.view.frame = CGRect(x : -self.view.frame.size.width,
y : 0,
width : menuVC.view.frame.size.width,
height: self.view.frame.size.height)
UIView.animate(withDuration: 0.5) {
menuVC.view.frame = CGRect(x : 0,
y : 0,
width : menuVC.view.frame.size.width,
height: self.view.frame.size.height)
}
- To remove menu
menuVC.view.frame = CGRect(x : 0,
y : 0,
width : menuVC.view.frame.size.width,
height: self.view.frame.size.height)
UIView.animate(withDuration: 0.5) {
menuVC.view.frame = CGRect(x : -self.view.frame.size.width,
y : 0,
width : menuVC.view.frame.size.width,
height: self.view.frame.size.height)
}
HOPE: you can give constraints to you view.