Rah*_*ngh 6 ios swift uialertcontroller
我想要这样的警报对话框。其中包含一个可点击的链接,例如蓝色突出显示的文本。当用户单击该文本时,它将在浏览器中打开一个链接。为此,我正在使用第三方库SimpleAlert
这是我的代码...
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)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4299 次 |
| 最近记录: |