您可以订阅自定义TextField:
import UIKit
class CustomTextField: UITextField {
var inset:CGFloat = 12 // You can set the inset you want
override func textRect(forBounds bounds: CGRect) -> CGRect {
return bounds.insetBy(dx: inset, dy: 0)
}
override func editingRect(forBounds bounds: CGRect) -> CGRect {
return bounds.insetBy(dx: inset, dy: 0)
}
}
结果,您可以看到CustomTextField的插图:
编辑
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句