-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomCell.swift
46 lines (38 loc) · 1.81 KB
/
CustomCell.swift
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
// Created by Amit Thakur on 10/09/20.
// Copyright © 2020 Amit Thakur. All rights reserved.
import Foundation
import UIKit
class CustomCell: UITableViewCell {
override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
super.init(style: style, reuseIdentifier: reuseIdentifier)
setupVeiw()
}
let containerView: UIView = {
let view = UIView()
view.translatesAutoresizingMaskIntoConstraints = false
view.backgroundColor = UIColor.white
return view
}()
let nameLabel: UILabel = {
let label = UILabel()
label.translatesAutoresizingMaskIntoConstraints = false
label.numberOfLines = 0
return label
}()
func setupVeiw(){
contentView.heightAnchor.constraint(greaterThanOrEqualToConstant: 70).isActive = true
contentView.addSubview(containerView)
containerView.addSubview(nameLabel)
containerView.leftAnchor.constraint(equalTo: contentView.leftAnchor).isActive = true
containerView.rightAnchor.constraint(equalTo: contentView.rightAnchor).isActive = true
containerView.topAnchor.constraint(equalTo: contentView.topAnchor).isActive = true
containerView.bottomAnchor.constraint(equalTo: contentView.bottomAnchor).isActive = true
nameLabel.leftAnchor.constraint(equalTo: containerView.leftAnchor, constant: 16).isActive = true
nameLabel.rightAnchor.constraint(equalTo: containerView.rightAnchor, constant: -8).isActive = true
nameLabel.centerYAnchor.constraint(equalTo: containerView.centerYAnchor).isActive = true
nameLabel.bottomAnchor.constraint(equalTo: containerView.bottomAnchor,constant: -5).isActive = true
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}