How to make an interactive link in the warning controller quick

Application screenshot

I need a warning dialog similar to this image. which contains an interactive link, such as blue highlighted text. when the user clicks on this text, he will open the link in the browser. For this I use a third-party library SimpleAlert

here is my code ...

func popUpMsg(){

    let msg = "\n Hi Rahul! Welcome back to the early access queue for the app, Once you've been accepted into the beta, we'll notify you using the contact info you have on file with Facebook. \n\n But just a second, if you haven't already done so, you can increase your odds of jumping ahead in the queue by telling us a little about yourself. Please complete our 4-question survey to give it a shot. \n" as NSString
    let range = msg.rangeOfString("complete our 4-question survey")

    let alert = SimpleAlert.Controller(title: "Early Access to Application", message: msg as String, style: .Alert)
    alert.configContentView = { view in
        if let view = view as? SimpleAlert.ContentView {
            view.titleLabel.textColor = UIColor.blackColor()
            view.titleLabel.font = UIFont.boldSystemFontOfSize(32)
            print(view.titleLabel.font)
            view.messageLabel.textColor = UIColor.grayColor()

            let attributedString = NSMutableAttributedString(string: msg as String)
            attributedString.addAttribute(NSLinkAttributeName, value: NSURL(string: "http://www.google.com")!, range: range)
            attributedString.addAttribute(NSUnderlineStyleAttributeName, value: NSNumber(int: 1), range: range)
            attributedString.addAttribute(NSUnderlineColorAttributeName, value: UIColor.whiteColor(), range: range)

            view.messageLabel.attributedText = attributedString
            view.messageLabel.font = UIFont(name: "arial", size: 27)
            print(view.messageLabel.font)

            view.textBackgroundView.layer.cornerRadius = 3.0
            view.textBackgroundView.clipsToBounds = true
        }
    }
    alert.addAction(SimpleAlert.Action(title: "OK", style: .OK))
    presentViewController(alert, animated: true, completion: nil)
}
+4
source share

All Articles