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?
Create a width constraint for your menuIconImageView
and 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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.