TabCollectionViewCell.swift
1.78 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
//
// tabCell.swift
// browser
//
// Created by Artem Talko on 25.09.2023.
//
import UIKit
final class TabCollectionViewCell: UICollectionViewCell {
let tabCellImage: UIImageView = {
let obj = UIImageView()
obj.contentMode = .scaleToFill
return obj
}()
let tabCellLabel: UILabel = {
let obj = UILabel()
obj.textColor = .black
obj.font = FontConstants.regularFont_14
return obj
}()
override init(frame: CGRect) {
super.init(frame: frame)
setup()
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
func setup() {
layer.cornerRadius = 10
contentView.backgroundColor = UIColor(red: 0.867, green: 0.867, blue: 0.863, alpha: 0.4)
contentView.layer.cornerRadius = 10
contentView.addSubview(tabCellImage)
contentView.addSubview(tabCellLabel)
setupConstraints()
}
private func setupConstraints() {
tabCellImage.snp.makeConstraints { make in
make.top.equalToSuperview().offset(14.sizeH)
make.leading.trailing.equalToSuperview().inset(9.sizeW)
make.height.equalTo(50.sizeW)
}
tabCellLabel.snp.makeConstraints { make in
make.centerX.equalToSuperview()
make.top.equalTo(tabCellImage.snp.bottom).offset(8.sizeH)
}
}
override func layoutSubviews() {
super.layoutSubviews()
shadowSetup()
}
}
//MARK: - Shadows
extension TabCollectionViewCell {
private func shadowSetup() {
layer.shadowColor = UIColor.gray.cgColor
layer.shadowOpacity = 0.2
layer.shadowRadius = 3
layer.shadowOffset = CGSize(width: 2, height: 2)
}
}