-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCustomButton.swift
44 lines (34 loc) · 1.12 KB
/
CustomButton.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
//
// CustomButton.swift
// EassyWorkOut
//
// Created by jeashan anuja on 2023-03-16.
//
import UIKit
class CustomButton: UIButton {
enum FontSize {
case big
case med
case small
}
init(title: String , hasBackground: Bool = false , fontSize: FontSize){
super.init(frame: .zero)
self.setTitle(title, for: .normal)
self.layer.cornerRadius = 20
self.layer.masksToBounds = true
self.backgroundColor = hasBackground ? .systemGreen : .clear
let titleColor: UIColor = hasBackground ? .white : .systemBlue
self.setTitleColor(titleColor , for: .normal)
switch fontSize {
case .big:
self.titleLabel?.font = .systemFont(ofSize: 22, weight: .bold)
case .med:
self.titleLabel?.font = .systemFont(ofSize: 18, weight: .semibold)
case.small:
self.titleLabel?.font = .systemFont(ofSize: 16, weight: .regular)
}
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}