12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- import UIKit
- class CommonViewToFill: NSObject {
-
- private var _vcView: UIView!
-
- private var _currentView: UIView!
-
- private var _parentView: UIView!
-
- private var _defaultIsShowNav = true
- private var isFill = false
- private var vcViewFrame: CGRect!
- private var currentViewFrame: CGRect!
-
- init(vcView: UIView, currentView: UIView, defaultIsShowNav: Bool) {
- super.init()
- _vcView = vcView
- _currentView = currentView
- _defaultIsShowNav = defaultIsShowNav
- _parentView = _currentView.superview!
- let videoViewGesture = UITapGestureRecognizer(target: self, action: #selector(videoClick))
- videoViewGesture.numberOfTapsRequired = 2
- _currentView.addGestureRecognizer(videoViewGesture)
- }
- @objc func videoClick(sender: UITapGestureRecognizer) {
- setIsFill(isFill: isFill)
- isFill = !isFill
- }
- func setIsFill(isFill: Bool) {
- if isFill {
- UIApplication.shared.setStatusBarHidden(false, with: .none)
- _currentView.removeFromSuperview()
- _parentView.addSubview(_currentView)
- UIView.animate(withDuration: 0.4, animations: {
- appDelegate.setNavigationBarHidden(isHidden: !self._defaultIsShowNav)
- self._vcView.transform = CGAffineTransform.inverted(CGAffineTransform(rotationAngle: CGFloat(0)))()
- self._vcView.frame = self.vcViewFrame
- self._currentView.frame = self.currentViewFrame
- }) { (_) in
- }
- } else {
- self.vcViewFrame = self._vcView.frame
- self.currentViewFrame = self._currentView.frame
- UIApplication.shared.setStatusBarHidden(true, with: .none)
- _currentView.removeFromSuperview()
- _vcView.addSubview(_currentView)
- _vcView.bringSubviewToFront(_currentView)
- UIView.animate(withDuration: 0.4, animations: {
- appDelegate.setNavigationBarHidden(isHidden: true)
- self._vcView.transform = CGAffineTransform(rotationAngle: CGFloat(Double.pi/2))
- self._vcView.frame = CGRect(x: 0, y: 0, width: ScreenHeight, height: ScreenWidth)
- self._currentView.frame = CGRect(x: 0, y: 0, width: ScreenHeight, height: ScreenWidth)
- }) { (_) in
- }
- }
- }
- }
|