CNLiveModalPresentationViewController.swift 1.4 KB
//
//  CNLiveModalPresentationViewController.swift
//  metaCode
//
//  Created by zx on 2023/11/16.
//

import Foundation

typealias completionBlock = (_ finished:Bool)->Void

class CNLiveModalPresentationViewController:UIViewController{
    
    var _contentView:UIView?
    var contentView:UIView?{
        get{
            _contentView
        }
        set{
            _contentView = newValue
            
        }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.view.backgroundColor = .clear
    }
    
    func showingAnimationWithCompletion(completion:@escaping completionBlock){
        
        self.contentView?.transform = CGAffineTransformMakeTranslation(0, self.view.height-(self.contentView?.top)!)

        UIView.animate(withDuration: 0.3, delay: 0.0, options: .curveEaseOut) {
            self.contentView?.transform = CGAffineTransformIdentity
        } completion: { finished in
            completion(finished)
        }
    }
    
    func hidingAnimationWithCompletion(completion:@escaping completionBlock){
        UIView.animate(withDuration: 0.3, delay: 0.0, options: .curveEaseOut) {
            self.contentView?.transform = CGAffineTransformMakeTranslation(0, self.view.height-self.contentView!.top)
        } completion: { finished in
            self.contentView?.transform = CGAffineTransformIdentity
            completion(finished)
        }
    }
    


}