Swift 如何进行UITextField填充
我有一个Swift应用程序。为了进行填充,我编写了以下代码:Swift 如何进行UITextField填充,swift,Swift,我有一个Swift应用程序。为了进行填充,我编写了以下代码: class TextField: UITextField { let padding = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 5) override open func textRect(forBounds bounds: CGRect) -> CGRect { return UIEdgeInsetsInsetRect(bounds, padding) }
class TextField: UITextField {
let padding = UIEdgeInsets(top: 0, left: 15, bottom: 0, right: 5)
override open func textRect(forBounds bounds: CGRect) -> CGRect {
return UIEdgeInsetsInsetRect(bounds, padding)
}
override open func placeholderRect(forBounds bounds: CGRect) -> CGRect {
return UIEdgeInsetsInsetRect(bounds, padding)
}
override open func editingRect(forBounds bounds: CGRect) -> CGRect {
return UIEdgeInsetsInsetRect(bounds, padding)
}
但今天我将我的项目转换为Swift 4.2,现在我有一个错误:
“UIEDGEINSETINSETINSERCT”已被实例方法“CGRect.inset(by:)”替换
如何修复它?替换
UIEdgeInsetsInsetRect(边界,填充)
为bounds。inset(by:padding)
替换UIEdgeInsetsInsetRect(边界,填充)
为bounds.inset(by:padding)UIEdgeInsetsInsetRect(边界,填充)
=bounds.inset(by:padding)
?uiedgeinsetinsetrect(边界,填充)
=>bounds.inset(by:padding)
?它可以工作!非常感谢你!!!它起作用了!非常感谢你!!!