Minor tweaks

This commit is contained in:
Shadowfacts 2019-09-24 22:01:25 -04:00
parent 07a6ddf1b9
commit 36a63e1e23
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
4 changed files with 6 additions and 4 deletions

View File

@ -23,7 +23,7 @@ class SheetContainerDismissAnimationController: NSObject, UIViewControllerAnimat
fromVC.dimmingView.isHidden = true
let dimmingView = UIView(frame: fromVC.view.frame)
dimmingView.backgroundColor = .systemGray
dimmingView.backgroundColor = fromVC.dimmingView.backgroundColor
dimmingView.alpha = fromVC.dimmingView.alpha
let container = transitionContext.containerView

View File

@ -24,7 +24,7 @@ class SheetContainerPresentationAnimationController: NSObject, UIViewControllerA
let finalFrame = transitionContext.finalFrame(for: toVC)
let dimmingView = UIView(frame: finalFrame)
dimmingView.backgroundColor = .systemGray
dimmingView.backgroundColor = toVC.dimmingView.backgroundColor
dimmingView.alpha = 0
let container = transitionContext.containerView

View File

@ -63,7 +63,7 @@ public class SheetContainerViewController: UIViewController {
dimmingView = UIView()
dimmingView.translatesAutoresizingMaskIntoConstraints = false
dimmingView.backgroundColor = .systemGray
dimmingView.backgroundColor = .black
dimmingView.alpha = (maximumDimmingAlpha - minimumDimmingAlpha) / 2
view.addSubview(dimmingView)
NSLayoutConstraint.activate([
@ -123,7 +123,7 @@ public class SheetContainerViewController: UIViewController {
self.topConstraint.constant = springToDetent.1
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.dimmingView.alpha = lerp(springToDetent.1, min: self.topDetent.offset, max: self.bottomDetent.offset, from: self.maximumDimmingAlpha, to: self.minimumDimmingAlpha)
}, completion: { (finished) in

View File

@ -21,6 +21,8 @@ class ViewController: UIViewController {
let content = UIViewController()
content.view.translatesAutoresizingMaskIntoConstraints = false
content.view.backgroundColor = .red
content.view.layer.masksToBounds = true
content.view.layer.cornerRadius = view.bounds.width * 0.05
let sheet = SheetContainerViewController(content: content)
sheet.delegate = self
sheet.detents = [.bottom, .middle, .top]