-
Notifications
You must be signed in to change notification settings - Fork 2
/
UITextField+Extension.swift
49 lines (38 loc) · 1.34 KB
/
UITextField+Extension.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
//
// UITextField+Extension.swift
// Shoaib
//
// Created by Shoaib Sarwar Cheema on 18/07/2017.
// Copyright © 2017. All rights reserved.
//
import UIKit
extension UITextField {
@IBInspectable var placeholderColor: UIColor {
get {
guard let currentAttributedPlaceholderColor = attributedPlaceholder?.attribute(NSForegroundColorAttributeName, at: 0, effectiveRange: nil) as? UIColor else { return UIColor.clear }
return currentAttributedPlaceholderColor
}
set {
guard let currentAttributedString = attributedPlaceholder else { return }
let attributes = [NSForegroundColorAttributeName : newValue]
attributedPlaceholder = NSAttributedString(string: currentAttributedString.string, attributes: attributes)
}
}
}
class LinedTextField: UITextField {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupView()
}
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
func setupView(){
borderStyle = .none
addBorder(.bottom, color: .white, thickness: 1)
placeholderColor = UIColor(red: 1, green: 1, blue: 1, alpha: 0.7)
textColor = UIColor.white
clipsToBounds = true
}
}