宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-07-05 0d8f5fc8a516bfd07e425909e4a4432600572ee7
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//
//  YYAlertNoneViewController.swift
//  FollowMeProject
//
//  Created by alvin_y on 2020/8/21.
//  Copyright © 2020 yangwang. All rights reserved.
//
 
import UIKit
import RxCocoa
import RxSwift
 
class YYAlertNoneViewController: YYViewController {
    
   
    /// 内容
    @IBOutlet weak var label_content: UILabel!
    
    var duration: Int = 2
 
    var textFieldText: String?
    var isAutoDismiss: Bool = true
    var onDone: onDoneBlock?
    var backgroundColor: UIColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 0)
    
    init (){
        super.init(nibName: String(describing: YYAlertNoneViewController.self), bundle: Bundle.main)
        modalTransitionStyle = .crossDissolve
        modalPresentationStyle = .overFullScreen
        
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    
   
    
    override func viewDidLoad() {
        super.viewDidLoad()
 
        // Do any additional setup after loading the view.
        view.backgroundColor = backgroundColor
        label_content.text = textFieldText
        
        Observable<Int>.interval(RxTimeInterval.seconds(1), scheduler: MainScheduler.instance)
            .subscribe(onNext: {[unowned self] (sec) in
                if sec >= self.duration{
                    self.dismiss(animated: true, completion: nil)
                    self.onDone?()
                }
            })
        .disposed(by: disposeBag)
    }
    
    
    class func display(text: String?,duration: Int = 2,backgroundColor: UIColor = .clear,onDone: @escaping () -> Void) {
        let vc = YYAlertNoneViewController()
        vc.textFieldText = text
        vc.backgroundColor = backgroundColor
        vc.onDone = onDone
        vc.duration = duration
        self.base()?.present(vc, animated: true, completion: nil)
    }
  
 
}