![](/img/trans.png)
[英]How can I create a custom TextCell and TextRow that has a subclass of UITextField in it?
[英]How can I make a custom subclass of uitextfield and over there using @IBDesignable & @IBInspectable I can set placholder padding from left
我想通过使用@IBDesignable和@IBInspectable设置UITextField的子类,并在其中设置文本的左侧和右侧填充以及占位符。 可以忽略左右视图。
为您的文本字段创建一个自定义类,并将您的文本字段类指定为CustomTextField
。
class CustomTextField: UITextField {
@IBInspectable var padding : CGFloat = 0 {
didSet{
let paddingView : UIView = UIView(frame: CGRect(x: 0, y: 0, width: padding, height: self.frame.size.height))
self.leftView = paddingView
self.rightView = paddingView
self.leftViewMode = .always
}
}
}
然后,您可以从情节提要中设置填充。 可以从情节提要中的“ Attributes Inspector
中设置占位符。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.