我以前使用过这个代码范围:
override func textRect(forBounds bounds: CGRect) -> CGRect {
super.textRect(forBounds: bounds)
return UIEdgeInsetsInsetRect(bounds, UIEdgeInsets(top: 0,left: 10, bottom: 0, right: 10))
}
但是它在 Xcode Swift Update 之后给出了一个错误。这是一个错误:
'UIEdgeInsetsInsetRect' has been replaced by instance method 'CGRect.inset(by:)'
然后我写了这个:
override func textRect(forBounds bounds: CGRect) -> CGRect {
super.textRect(forBounds: bounds)
var animationRect = frame.inset(by: UIEdgeInsets(top: 0, left: 5, bottom: 0, right: 10))
return animationRect
}
但是上面的代码不会影响到文本字段。我应该写什么来给左边的填充?