gpt4 book ai didi

swift - 如何制作 UITextField 填充

转载 作者:行者123 更新时间:2023-11-28 09:39:42 27 4
gpt4 key购买 nike

<分区>

我有一个 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)
}

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,现在出现错误:

'UIEdgeInsetsInsetRect' has been replaced by instance method 'CGRect.inset(by:)'

我该如何解决?

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com