导航器菜单从右侧滑入

时间:2018-12-04 19:33:51

标签: ios swift menu slide navigator

这是导航菜单的代码:

    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)

如何单击鼠标右键使菜单滑入?

1 个答案:

答案 0 :(得分:0)

为您的menuIconImageView创建一个宽度约束并将其初始值设置为0。单击按钮后,将宽度值设置为35,然后用UIView.animate(withDuration:){ view.layoutIfNeeded() }设置动画。另外,请确保您对superView具有跟踪约束,并且0的值设置为menuIconImageView

您可以在下面的线程中查看代码示例

How to animate a UIView with constraints in Swift?