forked from asharma381/Snapdemic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Utilities.swift
54 lines (38 loc) · 1.58 KB
/
Utilities.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
47
48
49
50
51
52
53
54
//
// Utilities.swift
// Allergio
//
// Created by Aditya Sharma on 6/23/20.
// Copyright © 2020 billx. All rights reserved.
//
import Foundation
import UIKit
class Utilities {
static func styleTextField(_ textfield:UITextField) {
// Create the bottom line
let bottomLine = CALayer()
bottomLine.frame = CGRect(x: 0, y: textfield.frame.height - 2, width: textfield.frame.width, height: 2)
bottomLine.backgroundColor = UIColor.init(red: 48/255, green: 173/255, blue: 99/255, alpha: 1).cgColor
// Remove border on text field
textfield.borderStyle = .none
// Add the line to the text field
textfield.layer.addSublayer(bottomLine)
}
static func styleFilledButton(_ button:UIButton) {
// Filled rounded corner style
button.backgroundColor = UIColor.init(red: 48/255, green: 173/255, blue: 99/255, alpha: 1)
button.layer.cornerRadius = 25.0
button.tintColor = UIColor.white
}
static func styleHollowButton(_ button:UIButton) {
// Hollow rounded corner style
button.layer.borderWidth = 2
button.layer.borderColor = UIColor.black.cgColor
button.layer.cornerRadius = 25.0
button.tintColor = UIColor.black
}
static func isPasswordValid(_ password : String) -> Bool {
let passwordTest = NSPredicate(format: "SELF MATCHES %@", "^(?=.*[a-z])(?=.*[$@$#!%*?&])[A-Za-z\\d$@$#!%*?&]{8,}")
return passwordTest.evaluate(with: password)
}
}