Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // SEUIChildManagingViewController.swift
- // ThreePanelSplitViewController
- //
- // Created by Brian Nickel on 6/21/17.
- // Copyright © 2017 Brian Nickel. All rights reserved.
- //
- import UIKit
- public enum AppearanceState {
- case disappeared, appeared
- case appearing(Bool)
- case disappearing(Bool)
- public var isAnimating: Bool {
- switch self {
- case .disappeared, .appeared:
- return false
- case .appearing(let animating):
- return animating
- case .disappearing(let animating):
- return animating
- }
- }
- }
- open class SEUIChildManagingViewController: UIViewController {
- private(set) public var childViewControllerContainers: [SEUIChildViewControllerContainer] = []
- public func add(_ childViewControllerContainer: SEUIChildViewControllerContainer, to superview: UIView) {
- childViewControllerContainers.append(childViewControllerContainer)
- superview.addSubview(childViewControllerContainer.containerView)
- childViewControllerContainer.parentTransitioned(to: appearanceState)
- }
- private(set) public var appearanceState: AppearanceState = .disappeared {
- didSet {
- for container in childViewControllerContainers {
- container.parentTransitioned(to: appearanceState)
- }
- }
- }
- open override var shouldAutomaticallyForwardAppearanceMethods: Bool {
- return false
- }
- open override func viewWillAppear(_ animated: Bool) {
- super.viewWillAppear(animated)
- appearanceState = .appearing(animated)
- }
- open override func viewDidAppear(_ animated: Bool) {
- super.viewDidAppear(animated)
- appearanceState = .appeared
- }
- open override func viewWillDisappear(_ animated: Bool) {
- super.viewWillDisappear(animated)
- appearanceState = .disappearing(animated)
- }
- open override func viewDidDisappear(_ animated: Bool) {
- appearanceState = .disappeared
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement