/
githubmirror
/
omim
Обзор
Документация
Войти
/
githubmirror
/
omim
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
iphone/Maps/Classes/Components/Modal/DimmedModalPresentationController.swift
50 строк
2 KB
Alexander Boriskov
[iOS] Refactored old styles
12 фев 2020, 14:37
12 фев 2020, 14:37
91d7242
Код
Авторство
О чём код?
class DimmedModalPresentationController: UIPresentationController { private lazy var onTapGr: UITapGestureRecognizer = { return UITapGestureRecognizer(target: self, action: #selector(onTap)) }() private lazy var dimView: UIView = { let view = UIView() view.styleName = "BlackStatusBarBackground" if isCancellable { view.addGestureRecognizer(onTapGr) } return view }() let isCancellable: Bool required init(presentedViewController: UIViewController, presenting presentingViewController: UIViewController?, cancellable: Bool = true) { isCancellable = cancellable super.init(presentedViewController: presentedViewController, presenting: presentingViewController) } @objc private func onTap() { presentingViewController.dismiss(animated: true, completion: nil) } override func presentationTransitionWillBegin() { guard let containerView = containerView else { return } containerView.addSubview(dimView) dimView.frame = containerView.bounds dimView.autoresizingMask = [.flexibleWidth, .flexibleHeight] dimView.alpha = 0 presentingViewController.transitionCoordinator?.animate(alongsideTransition: { _ in self.dimView.alpha = 1 }) } override func presentationTransitionDidEnd(_ completed: Bool) { if !completed { dimView.removeFromSuperview() } } override func dismissalTransitionWillBegin() { presentingViewController.transitionCoordinator?.animate(alongsideTransition: { _ in self.dimView.alpha = 0 }) } override func dismissalTransitionDidEnd(_ completed: Bool) { if completed { dimView.removeFromSuperview() } } }