/
githubmirror
/
omim
Обзор
Документация
Войти
/
githubmirror
/
omim
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
iphone/Maps/Classes/Components/DimBackground.swift
42 строки
1 KB
Alexander Boriskov
[iOS] Refactored old styles
12 фев 2020, 14:37
12 фев 2020, 14:37
91d7242
Код
Авторство
О чём код?
@objc(MWMDimBackground) final class DimBackground: SolidTouchView { private let mainView: UIView private var tapAction: () -> Void @objc init(mainView: UIView, tapAction: @escaping () -> Void) { self.mainView = mainView self.tapAction = tapAction super.init(frame: mainView.superview!.bounds) styleName = "FadeBackground" autoresizingMask = [.flexibleWidth, .flexibleHeight] addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(onTap))) } required init?(coder _: NSCoder) { fatalError("init(coder:) has not been implemented") } @objc func setVisible(_ visible: Bool, completion: (() -> Void)?) { if visible { let sv = mainView.superview! frame = sv.bounds sv.insertSubview(self, belowSubview: mainView) alpha = 0 } else { alpha = 0.8 } UIView.animate(withDuration: kDefaultAnimationDuration, animations: { self.alpha = visible ? 0.8 : 0 }, completion: { _ in if !visible { self.removeFromSuperview() } completion?() }) } @objc private func onTap() { tapAction() } }