我有UITextField
:
let promoTextField: UITextField = {
let textField = UITextField()
textField.font = UIFont.systemFont(ofSize: 32, weight: UIFont.Weight.light)
textField.placeholder = NSLocalizedString("PromoCode", comment: "")
textField.textAlignment = .center
textField.translatesAutoresizingMaskIntoConstraints = false
textField.minimumFontSize = 17
textField.adjustsFontSizeToFitWidth = true
return textField
}()
可以根据设备屏幕大小更改UITextField
高度(仅高度)。我需要根据UITextField
hight自动更改字体大小。怎么做?
答案 0 :(得分:0)
label.minimumScaleFactor = 0.1 // your value
label.adjustsFontSizeToFitWidth = true
label.lineBreakMode = .byClipping
label.numberOfLines = 0