如何在警报中更改 UITextField 字体大小

问题描述 投票:0回答:1

我正在尝试使当前放置在警报中的文本字段中的字体大小更大:

func showAlert() {
    let ac = UIAlertController(title: "Title", message: "Message", preferredStyle: .alert)
    
    // Add text field
    ac.addTextField(configurationHandler: { textField in
        
        
        let heightConstraint = NSLayoutConstraint(item: textField, attribute: .height, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 100)
        textField.addConstraint(heightConstraint)
   
        textField.minimumFontSize = 100
        
    })
swift uitextfield uialertcontroller
1个回答
1
投票

textField.minimumFontSize = 100
线更改为
textField.font = UIFont(name: "*whateverFontNameYouAreUsing*", size: 30)
。让我知道这是否有效。谢谢。

check this code and font size in simulator here

© www.soinside.com 2019 - 2024. All rights reserved.