宽窄优行-由【嘉易行】项目成品而来
younger_times
2023-04-11 4356615a9252a987a62469331b1fcf91c102e24c
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
//
//  EKXStatusBarMessageView.swift
//  SwiftEntryKit
//
//  Created by Daniel Huri on 4/19/18.
//  Copyright (c) 2018 huri000@gmail.com. All rights reserved.
//
 
import UIKit
import QuickLayout
 
public class EKXStatusBarMessageView: UIView {
    
    // MARK: Props
    private let leadingLabel = UILabel()
    private let trailingLabel = UILabel()
    
    // MARK: Setup
    public init(leading: EKProperty.LabelContent, trailing: EKProperty.LabelContent) {
        super.init(frame: UIScreen.main.bounds)
        setup(leading: leading, trailing: trailing)
    }
    
    public required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    private func setup(leading: EKProperty.LabelContent, trailing: EKProperty.LabelContent) {
        clipsToBounds = true
        
        set(.height, of: UIApplication.shared.statusBarFrame.maxY)
        
        addSubview(leadingLabel)
        leadingLabel.content = leading
        
        leadingLabel.layoutToSuperview(axis: .vertically)
        leadingLabel.layoutToSuperview(.leading)
        leadingLabel.layoutToSuperview(.width, ratio: 0.26)
        
        addSubview(trailingLabel)
        trailingLabel.content = trailing
        
        trailingLabel.layoutToSuperview(axis: .vertically)
        trailingLabel.layoutToSuperview(.trailing)
        trailingLabel.layoutToSuperview(.width, ratio: 0.26)
    }
}