Add background dimming view
This commit is contained in:
parent
1eea2313cd
commit
9ddd39da4c
|
@ -32,11 +32,13 @@ public class SheetContainerViewController: UIViewController {
|
||||||
return detents.map { ($0, $0.offset(in: view)) }.min(by: { $0.1 < $1.1 })!
|
return detents.map { ($0, $0.offset(in: view)) }.min(by: { $0.1 < $1.1 })!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public var minimumDetentJumpVelocity: CGFloat = 500
|
||||||
|
public var maximumStretchDistance: CGFloat = 15
|
||||||
|
|
||||||
var topConstraint: NSLayoutConstraint!
|
var topConstraint: NSLayoutConstraint!
|
||||||
lazy var initialConstant: CGFloat = view.bounds.height / 2
|
lazy var initialConstant: CGFloat = view.bounds.height / 2
|
||||||
|
|
||||||
public var minimumDetentJumpVelocity: CGFloat = 500
|
var dimmingView: UIView!
|
||||||
public var maximumStretchDistance: CGFloat = 15
|
|
||||||
|
|
||||||
public init(content: UIViewController) {
|
public init(content: UIViewController) {
|
||||||
self.content = content
|
self.content = content
|
||||||
|
@ -51,6 +53,18 @@ public class SheetContainerViewController: UIViewController {
|
||||||
override public func viewDidLoad() {
|
override public func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
|
||||||
|
dimmingView = UIView()
|
||||||
|
dimmingView.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
dimmingView.backgroundColor = .systemGray
|
||||||
|
dimmingView.alpha = 0.5
|
||||||
|
view.addSubview(dimmingView)
|
||||||
|
NSLayoutConstraint.activate([
|
||||||
|
dimmingView.leadingAnchor.constraint(equalTo: view.leadingAnchor),
|
||||||
|
dimmingView.trailingAnchor.constraint(equalTo: view.trailingAnchor),
|
||||||
|
dimmingView.topAnchor.constraint(equalTo: view.topAnchor),
|
||||||
|
dimmingView.bottomAnchor.constraint(equalTo: view.bottomAnchor)
|
||||||
|
])
|
||||||
|
|
||||||
addChild(content)
|
addChild(content)
|
||||||
content.didMove(toParent: self)
|
content.didMove(toParent: self)
|
||||||
view.addSubview(content.view)
|
view.addSubview(content.view)
|
||||||
|
|
|
@ -14,6 +14,7 @@ class ViewController: UIViewController {
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
// Do any additional setup after loading the view.
|
// Do any additional setup after loading the view.
|
||||||
|
view.backgroundColor = .green
|
||||||
|
|
||||||
let content = UIViewController()
|
let content = UIViewController()
|
||||||
content.view.translatesAutoresizingMaskIntoConstraints = false
|
content.view.translatesAutoresizingMaskIntoConstraints = false
|
||||||
|
@ -21,7 +22,7 @@ class ViewController: UIViewController {
|
||||||
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]
|
||||||
sheet.view.backgroundColor = .blue
|
// sheet.view.backgroundColor = .blue
|
||||||
|
|
||||||
addChild(sheet)
|
addChild(sheet)
|
||||||
sheet.didMove(toParent: self)
|
sheet.didMove(toParent: self)
|
||||||
|
|
Loading…
Reference in New Issue