Swift UIAlertController with url in text

痴心易碎 提交于 2020-02-24 16:16:30

问题


I have this code:

func alertBox(txt: String){
        let ac = UIAlertController(title: "MyTtle" , message: "More information in my website: ", preferredStyle: .alert)
        let ramkaNaObrazek = CGRect(origin: CGPoint(x: 10, y: 10), size: CGSize(width: 30, height: 30))
        let ikonaAlertu = UIImageView(frame: ramkaNaObrazek)
        ikonaAlertu.image = UIImage(named: "modal_podpowiedz")
        ac.view.addSubview(ikonaAlertu)
        ac.addAction(UIAlertAction(title: "Ok" , style: .cancel, handler: { (action: UIAlertAction!) in
        }))
        present(ac, animated: true)
    }

I would like to add after this text: "More information in my website:" + www - a link to my website (http://www.myname.pl).

How can I do this?


回答1:


You can't add custom fields like text views with clickable links to a UIAlertController. You will need to either create your own modal view controller that acts like a UIAlertController or use a third party framework that does it for you.



来源:https://stackoverflow.com/questions/49754343/swift-uialertcontroller-with-url-in-text

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!