如何解决如何在警报标题的右侧显示图像视图?
我想在警报视图标题旁边显示图像视图。为此,我添加了以下代码,但是我的问题是,警报标题和图像视图之间显示的空间太大。
let attributedString = NSAttributedString(string: "Delete",attributes: [NSAttributedString.Key.foregroundColor : UIColor(named: "TextColor")!])
let attributedMessageString = NSAttributedString(string: "Should the set heating time really be deleted?",attributes: [NSAttributedString.Key.foregroundColor : UIColor(named: "TextColor")!])
let alert = UIAlertController(title: "",message: "",preferredStyle: .alert)
alert.setValue(attributedString,forKey: "attributedTitle")
alert.setValue(attributedMessageString,forKey: "attributedMessage")
alert.addAction(UIAlertAction(title: "Abort",style: .default,handler: nil))
alert.addAction(UIAlertAction(title: "Delete",handler: {(action:UIAlertAction!) in
self.startTimeTextField.text = "--:--"
}))
let imgTitle = UIImage(named:"ArrowUpImage")
let imgViewTitle = UIImageView(frame: CGRect(x: alert.view.center.x,y: 15,width: 30,height: 30))
imgViewTitle.image = imgTitle
alert.view.addSubview(imgViewTitle)
let subview = (alert.view.subviews.first?.subviews.first?.subviews.first!)! as UIView
subview.backgroundColor = UIColor(named: "BackgroundColor")
alert.view.tintColor = UIColor(named: "SpecialColor")
self.viewController.present(alert,animated: true,completion: nil)
我希望我的警报视图看起来像下面的图像(警报视图标题和图像视图之间的空间只有10个)。
你能帮我吗?
解决方法
使用NSTextAttachment-
let checkboxValue = xyz
document.querySelectorAll("input[value="+checkboxValue+"]")[0].checked = false;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。