【发布时间】:2020-07-21 10:47:57
【问题描述】:
我正在为搜索栏创建一个自定义文本字段。我需要自定义字体和字体颜色。虽然它在 iOS 11-12.* 上正常工作,但在 iOS 13 上它的框架变小,因此占位符被截断。仅供参考,我为此使用了属性占位符。我怎样才能阻止这种情况?
class SearchBar: UITextField {
@IBInspectable var placeholderText : String = "" {
didSet {
self.attributedPlaceholder = NSAttributedString(string: placeholderText, attributes: [NSAttributedString.Key.foregroundColor: UIColor.white, NSAttributedString.Key.font: UIFont.appFont(size: 14.0)])
}
}
【问题讨论】:
标签: ios swift uikit uitextfield ios13