宽窄优行-由【嘉易行】项目成品而来
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
70
71
72
73
74
75
//
//  GYNoticeViewCell.swift
//  RollingNotice-Swift
//
//  Created by qm on 2017/12/14.
//  Copyright © 2017年 qm. All rights reserved.
//
 
import UIKit
 
 
let GYRollingDebugLog = false
 
open class GYNoticeViewCell: UIView {
    
    open private(set) lazy var contentView: UIView? = {
        let view = UIView()
        view.backgroundColor = UIColor.black
        self.addSubview(view)
        isAddedContentView = true
        return view
    }()
    
    open private(set) lazy var textLabel: UILabel? = {
        let lab = UILabel()
        self.contentView!.addSubview(lab)
        return lab
    }()
    
    @objc open private(set) var reuseIdentifier: String?
    fileprivate var isAddedContentView = false
    
    public override init(frame: CGRect) {
        super.init(frame: frame)
    }
    public required init(reuseIdentifier: String?){
        super.init(frame: CGRect.zero)
        if GYRollingDebugLog {
            print("init a cell from code: %p", self)
        }
        self.reuseIdentifier = reuseIdentifier
        setupInitialUI()
    }
    
    public required init?(coder aDecoder: NSCoder){
        super.init(coder: aDecoder)
        if GYRollingDebugLog {
            print("init a cell from xib")
        }
        
    }
    
    override open func layoutSubviews() {
        super.layoutSubviews()
        
        if isAddedContentView {
            self.contentView!.frame = self.bounds
            self.textLabel!.frame = CGRect.init(x: 10, y: 0, width: self.frame.size.width - 20, height: self.frame.size.height)
        }
        
    }
    
    deinit {
        
        if GYRollingDebugLog {
            print(#function)
        }
    }
}
 
extension GYNoticeViewCell{
    fileprivate func setupInitialUI() {
        self.backgroundColor = UIColor.white
    }
}