CNLiveModalPresentationViewController.swift
1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
//
// 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: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: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)
}
}
}