Minor tweaks
This commit is contained in:
parent
07a6ddf1b9
commit
36a63e1e23
|
@ -23,7 +23,7 @@ class SheetContainerDismissAnimationController: NSObject, UIViewControllerAnimat
|
||||||
fromVC.dimmingView.isHidden = true
|
fromVC.dimmingView.isHidden = true
|
||||||
|
|
||||||
let dimmingView = UIView(frame: fromVC.view.frame)
|
let dimmingView = UIView(frame: fromVC.view.frame)
|
||||||
dimmingView.backgroundColor = .systemGray
|
dimmingView.backgroundColor = fromVC.dimmingView.backgroundColor
|
||||||
dimmingView.alpha = fromVC.dimmingView.alpha
|
dimmingView.alpha = fromVC.dimmingView.alpha
|
||||||
|
|
||||||
let container = transitionContext.containerView
|
let container = transitionContext.containerView
|
||||||
|
|
|
@ -24,7 +24,7 @@ class SheetContainerPresentationAnimationController: NSObject, UIViewControllerA
|
||||||
let finalFrame = transitionContext.finalFrame(for: toVC)
|
let finalFrame = transitionContext.finalFrame(for: toVC)
|
||||||
|
|
||||||
let dimmingView = UIView(frame: finalFrame)
|
let dimmingView = UIView(frame: finalFrame)
|
||||||
dimmingView.backgroundColor = .systemGray
|
dimmingView.backgroundColor = toVC.dimmingView.backgroundColor
|
||||||
dimmingView.alpha = 0
|
dimmingView.alpha = 0
|
||||||
|
|
||||||
let container = transitionContext.containerView
|
let container = transitionContext.containerView
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class SheetContainerViewController: UIViewController {
|
||||||
|
|
||||||
dimmingView = UIView()
|
dimmingView = UIView()
|
||||||
dimmingView.translatesAutoresizingMaskIntoConstraints = false
|
dimmingView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
dimmingView.backgroundColor = .systemGray
|
dimmingView.backgroundColor = .black
|
||||||
dimmingView.alpha = (maximumDimmingAlpha - minimumDimmingAlpha) / 2
|
dimmingView.alpha = (maximumDimmingAlpha - minimumDimmingAlpha) / 2
|
||||||
view.addSubview(dimmingView)
|
view.addSubview(dimmingView)
|
||||||
NSLayoutConstraint.activate([
|
NSLayoutConstraint.activate([
|
||||||
|
@ -123,7 +123,7 @@ public class SheetContainerViewController: UIViewController {
|
||||||
self.topConstraint.constant = springToDetent.1
|
self.topConstraint.constant = springToDetent.1
|
||||||
let springVelocity = velocity.y / springDistance
|
let springVelocity = velocity.y / springDistance
|
||||||
|
|
||||||
UIView.animate(withDuration: 0.35, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: springVelocity, animations: {
|
UIView.animate(withDuration: 0.35, delay: 0, usingSpringWithDamping: 0.75, initialSpringVelocity: springVelocity, animations: {
|
||||||
self.view.layoutIfNeeded()
|
self.view.layoutIfNeeded()
|
||||||
self.dimmingView.alpha = lerp(springToDetent.1, min: self.topDetent.offset, max: self.bottomDetent.offset, from: self.maximumDimmingAlpha, to: self.minimumDimmingAlpha)
|
self.dimmingView.alpha = lerp(springToDetent.1, min: self.topDetent.offset, max: self.bottomDetent.offset, from: self.maximumDimmingAlpha, to: self.minimumDimmingAlpha)
|
||||||
}, completion: { (finished) in
|
}, completion: { (finished) in
|
||||||
|
|
|
@ -21,6 +21,8 @@ class ViewController: UIViewController {
|
||||||
let content = UIViewController()
|
let content = UIViewController()
|
||||||
content.view.translatesAutoresizingMaskIntoConstraints = false
|
content.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
content.view.backgroundColor = .red
|
content.view.backgroundColor = .red
|
||||||
|
content.view.layer.masksToBounds = true
|
||||||
|
content.view.layer.cornerRadius = view.bounds.width * 0.05
|
||||||
let sheet = SheetContainerViewController(content: content)
|
let sheet = SheetContainerViewController(content: content)
|
||||||
sheet.delegate = self
|
sheet.delegate = self
|
||||||
sheet.detents = [.bottom, .middle, .top]
|
sheet.detents = [.bottom, .middle, .top]
|
||||||
|
|
Loading…
Reference in New Issue