| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- //
- // RoundTextField.swift
- // Sirani
- //
- // Created by Anhar Solehudin on 26/03/19.
- // Copyright © 2019 Anhar Solehudin. All rights reserved.
- //
- import UIKit
- @IBDesignable
- class RoundTextField: UITextField {
-
- let padding = UIEdgeInsets(top: 0, left: 16, bottom: 0, right: 16)
-
- override open func textRect(forBounds bounds: CGRect) -> CGRect {
- return bounds.inset(by: padding)
- }
-
- override open func placeholderRect(forBounds bounds: CGRect) -> CGRect {
- return bounds.inset(by: padding)
- }
-
- override open func editingRect(forBounds bounds: CGRect) -> CGRect {
- return bounds.inset(by: padding)
- }
-
- override func prepareForInterfaceBuilder() {
- customizeView()
- }
-
- override func awakeFromNib() {
- super.awakeFromNib()
- customizeView()
- }
-
- func customizeView() {
- backgroundColor = #colorLiteral(red: 1.0, green: 1.0, blue: 1.0, alpha: 1.0)
- textColor = UIColor(red: 26/255, green: 29/255, blue: 38/255, alpha: 1.0)
- tintColor = #colorLiteral(red: 0.1056468859, green: 0.26498940589999997, blue: 0.5374458432, alpha: 1)
- layer.cornerRadius = 8.0
- layer.borderWidth = 1.0
- layer.borderColor = #colorLiteral(red: 0.88, green: 0.90, blue: 0.94, alpha: 1)
- }
-
- func getText() -> String? {
- return self.text?.trimmingCharacters(in: .whitespacesAndNewlines)
- }
- }
|