[英]How can I add padding to UIImageView that is inside of a rightView of a UITextField?
[英]How can i set a Padding for the Text in UITextField
您可以制作自定義填充的 TextField。 你可以嘗試這樣的事情
class PaddedTextFeild: UITextField {
let padding = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 5)
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)
}
}
您可以嘗試按原樣使用此 class。 並更改第一行中定義的 UIEdgeInsets。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.