答案 0 :(得分:2)
我认为它不能单独在故事板上实现......
frame & alpha
操作。答案 1 :(得分:1)
这不是最近的问题,所以我把它放在以后使用。希望你已经成功了。
首先,您需要按原样关注this UIPresentationController guide。
然后将显示的视图控制器框架调整为大于屏幕的2/3。
override func containerViewWillLayoutSubviews() {
presentedView?.frame = frameOfPresentedViewInContainerView
presentedView?.layer.cornerRadius = 5.0
presentedView?.layer.masksToBounds = true
}
override func size(forChildContentContainer container: UIContentContainer,
withParentContainerSize parentSize: CGSize) -> CGSize {
switch direction {
case .left, .right:
return CGSize(width: parentSize.width*(2.0/3.0), height: parentSize.height)
case .bottom, .top:
return CGSize(width: parentSize.width, height: parentSize.height-40.0)
}
}
override var frameOfPresentedViewInContainerView: CGRect {
var frame: CGRect = .zero
frame.size = size(forChildContentContainer: presentedViewController,
withParentContainerSize: containerView!.bounds.size)
switch direction {
case .right:
frame.origin.x = containerView!.frame.width*(1.0/3.0)
case .bottom:
frame.origin.y = 40.0
default:
frame.origin = .zero
}
return frame
}
然后在调光动画期间设置呈现视图控制器框架。
self.presentingFrame = self.presentingViewController.view.frame
var frame = self.presentingFrame
frame.size.width -= 40.0
frame.size.height -= 60.0
frame.origin.x += 20.0
frame.origin.y += 30.0
coordinator.animate(alongsideTransition: { _ in
self.dimmingView.alpha = 1.0
self.presentingViewController.view.frame = frame
self.presentingViewController.view.layer.cornerRadius = 5.0
self.presentingViewController.view.layer.masksToBounds = true
UIApplication.shared.statusBarStyle = .lightContent
})
不要忘记添加反向动画。结果: