PickerViewCell.swift
2.01 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
//
// PickerView.swift
// InterQR-Internship
//
// Created by Дмитрий Тимофеев on 01.06.2022.
//
import UIKit
final class PickerView: UIView {
private let iconView: UIImageView = {
var obj = UIImageView()
obj.contentMode = .scaleAspectFill
obj.layer.cornerRadius = 10
return obj
}()
private let label: UILabel = {
var obj = UILabel()
obj.textColor = UIColor(red: 50/255, green: 55/255, blue: 85/255, alpha: 1)
obj.font = UIFont(name: SkModernistFontType.bold.rawValue, size: 15)
return obj
}()
private let countryCode: UILabel = {
var obj = UILabel()
obj.textColor = UIColor(red: 50/255, green: 55/255, blue: 85/255, alpha: 1)
obj.font = UIFont(name: SkModernistFontType.bold.rawValue, size: 15)
return obj
}()
override init(frame: CGRect) {
super.init(frame: frame)
layout()
}
required init?(coder: NSCoder) {
super.init(coder: coder)
layout()
}
private func layout() {
addSubview(iconView)
addSubview(label)
addSubview(countryCode)
iconView.snp.makeConstraints { make in
make.leading.equalToSuperview().offset(25)
make.centerY.equalTo(snp.centerY)
// make.top.bottom.equalToSuperview()
make.height.width.equalTo(20)
}
label.snp.makeConstraints { make in
make.leading.equalTo(iconView.snp.trailing).offset(20)
make.top.bottom.equalToSuperview()
}
countryCode.snp.makeConstraints { make in
make.trailing.equalToSuperview().offset(-25)
make.top.bottom.equalToSuperview()
}
}
static func create(icon: UIImage, title: String, code: String) -> PickerView {
let numberView = PickerView()
numberView.iconView.image = icon
numberView.label.text = title
numberView.countryCode.text = code
return numberView
}
}