设想:
我创建了一个“attributeView”(UITableView),它是一个子视图(即容器 UIViewController 的视图的成员 UIViewController 的视图),将沿父视图的右上角显示。
它由上下文 (UITableView) 菜单的用户选择(未显示)激活。
目标:将此 UIView 动画化为从屏幕右边缘 滑动的视图。
基本上,就像一个滑动抽屉。
以下 snapkit 代码定位属性视图。我正在考虑从零宽度视图开始,然后动画到全宽:
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)
但这不起作用。我尝试了各种使用 snapkit 为宽度设置动画的方法。但我无法让它从右边缘滑入视野。
这样做的正确方法是什么?
还是我必须在没有 snapkit 的情况下手动定位视图并从那里开始?