73 lines
2.6 KiB
Swift
73 lines
2.6 KiB
Swift
//
|
|
// ViewController.swift
|
|
// SheetImagePickerTest
|
|
//
|
|
// Created by Shadowfacts on 9/23/19.
|
|
// Copyright © 2019 Shadowfacts. All rights reserved.
|
|
//
|
|
|
|
import UIKit
|
|
import SheetImagePicker
|
|
|
|
class ViewController: UIViewController {
|
|
|
|
override func viewDidLoad() {
|
|
super.viewDidLoad()
|
|
// Do any additional setup after loading the view.
|
|
view.backgroundColor = .green
|
|
}
|
|
|
|
@IBAction func plainPressed(_ sender: Any) {
|
|
let content = UIViewController()
|
|
content.view.translatesAutoresizingMaskIntoConstraints = false
|
|
let blurEffect = UIBlurEffect(style: .systemChromeMaterial)
|
|
let blurView = UIVisualEffectView(effect: blurEffect)
|
|
blurView.translatesAutoresizingMaskIntoConstraints = false
|
|
let label = UILabel()
|
|
label.translatesAutoresizingMaskIntoConstraints = false
|
|
label.text = "Hello, sheet!"
|
|
blurView.contentView.addSubview(label)
|
|
content.view.addSubview(blurView)
|
|
NSLayoutConstraint.activate([
|
|
content.view.leadingAnchor.constraint(equalTo: blurView.contentView.leadingAnchor),
|
|
content.view.trailingAnchor.constraint(equalTo: blurView.contentView.trailingAnchor),
|
|
content.view.topAnchor.constraint(equalTo: blurView.contentView.topAnchor),
|
|
content.view.bottomAnchor.constraint(equalTo: blurView.contentView.bottomAnchor),
|
|
label.centerXAnchor.constraint(equalTo: blurView.contentView.centerXAnchor),
|
|
label.centerYAnchor.constraint(equalTo: blurView.contentView.centerYAnchor)
|
|
])
|
|
|
|
let sheet = SheetContainerViewController(content: content)
|
|
sheet.delegate = self
|
|
sheet.detents = [.bottom, .middle, .top]
|
|
|
|
present(sheet, animated: true)
|
|
}
|
|
|
|
@IBAction func tablePressed(_ sender: Any) {
|
|
let content = ContentTableViewController()
|
|
content.view.translatesAutoresizingMaskIntoConstraints = false
|
|
content.view.layer.masksToBounds = true
|
|
content.view.layer.cornerRadius = view.bounds.width * 0.02
|
|
|
|
let sheet = SheetContainerViewController(content: content)
|
|
sheet.delegate = self
|
|
sheet.detents = [.bottom, .middle, .top]
|
|
|
|
present(sheet, animated: true)
|
|
}
|
|
|
|
@IBAction func navPressed(_ sender: Any) {
|
|
}
|
|
}
|
|
|
|
extension ViewController: SheetContainerViewControllerDelegate {
|
|
func sheetContainer(_ sheetContainer: SheetContainerViewController, willSnapToDetent detent: Detent) -> Bool {
|
|
if detent == .bottom {
|
|
sheetContainer.dismiss(animated: true)
|
|
return false
|
|
}
|
|
return true
|
|
}
|
|
}
|