gpt4 book ai didi

ios - UIAlertController Title 标题没有响应?

转载 作者:行者123 更新时间:2023-11-30 11:58:06 25 4
gpt4 key购买 nike

我的应用程序响应 swift ,如果显示警报并且用户增加字体大小,则警报消息的字体大小会增加,但警报标题的字体大小不会增加。我正在使用下面的代码来显示 UIAlertController。

let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.alert)

//Swift 2.0
let deleteAction = UIAlertAction(title: deleteBtnText, style: UIAlertActionStyle.destructive, handler: deleteHandler)
alert.addAction(deleteAction)

let cancelAction = UIAlertAction(title: cancelBtnText, style: UIAlertActionStyle.cancel, handler: cancelHandler)
alert.addAction(cancelAction)

// Set light teal color for alert tint color
alert.view.tintColor = UIColor.LTColor()
// set background color for text
let dictTitleColor = [NSAttributedStringKey.foregroundColor: UIColor.LTColor()]
let titleAttributedString = NSMutableAttributedString(string: title, attributes: dictTitleColor)
alert.setValue(titleAttributedString, forKey: "attributedTitle")

let appDelegate = UIApplication.shared.delegate as! AppDelegate
UIUtils.stopIndicator()

if let presented = appDelegate.window?.rootViewController?.presentedViewController {
presented.present(alert, animated: true, completion: nil)
} else {
appDelegate.window?.rootViewController?.present(alert, animated: true, completion: nil)
}

//Swift 2.0 by Nikhil
// Set light teal color for alert tint color
alert.view.tintColor = UIColor.LTColor()
return alert

最佳答案

您正在使用属性字符串来设置警报标题,这就是您的字体保持不变的原因。您可以使用 NSAttributedStringKey.font 在 dictTitleColor 中更改它。

关于ios - UIAlertController Title 标题没有响应?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47567652/

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