0

This is code for navigator menu:

    let menuIconImageView = UIImageView(image: UIImage(named: "menu_icon"))
    menuIconImageView.contentMode = .scaleAspectFit
    menuIconImageView.frame = CGRect(x: 35, y: 30, width: 35, height: 30)
    menuIconImageView.isUserInteractionEnabled = false
    self.view.addSubview(menuIconImageView)

How do I make a menu slide in from right on a click?

Roman Pokrovskij
  • 9,449
  • 21
  • 87
  • 142

1 Answers1

0

Create a width constraint for your menuIconImageViewand set it to 0 for it's initial value. Once you click on the button set the width value to 35 then animate with UIView.animate(withDuration:){ view.layoutIfNeeded() }. Also make sure that you have a trailing constraint to superView and the value is set to 0 for your menuIconImageView.

You can check below thread for code examples

How to animate a UIView with constraints in Swift?

lionserdar
  • 2,022
  • 1
  • 18
  • 21