Scenario:
I've created an 'attributeView' (UITableView) that is a subview (i.e., a member UIViewController's view of a container UIViewController's view) to be displayed along the right corner of the parent view.
It is activated by a contextual (UITableView) menu's user selection (not seen).
Goal: To animate this UIView as a sliding view from the right edge of the screen.
Basically, acting like a sliding drawer.
The following snapkit code positions the attributeView. I was thinking of starting out with a zero-width view, then animating to to full width:
public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
...
let attributeView = viewControllerToPresent.view
let containerView = presentingViewController?.view
presentingViewController?.addChildViewController(viewControllerToPresent)
containerView?.addSubview(attributeView!)
attributeView?.snp.makeConstraints { (make) in
make.width.equalTo(0.0)
make.top.equalTo(containerView!).offset(00.0)
make.right.equalTo(containerView!).offset(0.0)
make.bottom.equalTo(containerView!).offset(0.0)
}
UIView.animate(withDuration: 0.3,
animations: {
attributeView?.snp.updateConstraints { (update) in
update.width.equalTo(320.0)
}
self.layoutIfNeeded()
})
viewControllerToPresent.didMove(toParentViewController: presentingViewController)
But this doesn't work. I've tried various means of using snapkit to animate the width. But I can't get it to slide from the right edge into view.
What's the proper way to do this?
Or must I resort to positioning the view manually without snapkit and go from there?