28 lines
922 B
Swift
28 lines
922 B
Swift
//
|
|
// UITextField+Extensions.swift
|
|
// SHECommunity
|
|
//
|
|
// Created by psj on 2023/11/6.
|
|
//
|
|
|
|
import Foundation
|
|
import UIKit
|
|
|
|
extension UITextField {
|
|
func placeholderColor(placeholder: String, color: UIColor, font: UIFont = UIFont.systemFont(ofSize:15) ) {
|
|
// 字体大小
|
|
self.attributedPlaceholder = NSAttributedString.init(string:placeholder, attributes: [NSAttributedString.Key.font:font])
|
|
// 字体颜色
|
|
self.attributedPlaceholder = NSAttributedString.init(string:placeholder, attributes: [NSAttributedString.Key.foregroundColor:color])
|
|
}
|
|
|
|
/// EZSE: Add left padding to the text in textfield
|
|
public func addLeftTextPadding(_ blankSize: CGFloat) {
|
|
let leftView = UIView()
|
|
leftView.frame = CGRect(x: 0, y: 0, width: blankSize, height: frame.height)
|
|
self.leftView = leftView
|
|
self.leftViewMode = UITextField.ViewMode.always
|
|
}
|
|
|
|
}
|