Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // CustomTextField.swift
- // MyInterfaceTemplates
- //
- // Created by Константин Седлецкий on 10.01.2020.
- // Copyright © 2020 Бизнес.ру. All rights reserved.
- //
- import UIKit
- class CustomTextField: UITextField {
- let insets: UIEdgeInsets
- init(insets: UIEdgeInsets){
- self.insets = insets
- super.init(frame: .zero)
- self.layer.borderWidth = 1
- self.layer.cornerRadius = 5
- self.translatesAutoresizingMaskIntoConstraints = false
- self.heightAnchor.constraint(equalToConstant: 56).isActive = true
- self.keyboardType = .numberPad
- self.textColor = UIColor.white
- self.font = UIFont.init(name: "ProximaNova-Regular", size: 16)
- self.attributedPlaceholder = NSAttributedString(string: "", attributes: [
- .foregroundColor: UIColor.init(red: 141/255, green: 155/255, blue: 163/255, alpha: 0.5)
- ])
- }
- required init?(coder: NSCoder) {
- fatalError("init(coder:) has not been implemented")
- }
- override func textRect(forBounds bounds: CGRect) -> CGRect {
- return bounds.inset(by: insets)
- }
- override func editingRect(forBounds bounds: CGRect) -> CGRect {
- return bounds.inset(by: insets)
- }
- func setCornerRadius(cornerRadius: CGFloat) {
- self.layer.cornerRadius = cornerRadius
- }
- func setHeightAnchor(heightAnchor: CGFloat) {
- self.heightAnchor.constraint(equalToConstant: heightAnchor).isActive = true
- }
- func setBorderWidth(borderWidth: CGFloat) {
- self.layer.borderWidth = borderWidth
- }
- func setBorderColor(borderColor: UIColor) {
- self.layer.borderColor = borderColor.cgColor
- }
- func setAttributedPlaceholder(attributedPlaceholder: NSAttributedString) {
- self.attributedPlaceholder = attributedPlaceholder
- }
- func setKeyboardType(keyboardType: UIKeyboardType) {
- self.keyboardType = keyboardType
- }
- func setTextColor(textColor: UIColor) {
- self.textColor = textColor
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement