pmusolino / PMAlertController

PMAlertController is a great and customizable alert that can substitute UIAlertController
MIT License
2.52k stars 187 forks source link

Display HTML-String in inner description of PMAlertController #24

Closed quiKsilverItaly closed 8 years ago

quiKsilverItaly commented 8 years ago

Hello,

I am looking for an AlertController, which can display a text like this: http://www2.pic-upload.de/img/31474056/bornscreen.jpg Headings with bigger font, usual text with smaller font, displaying URLs and so on. It's one big String with HTML-Code.

Can the description-attribute of PMAlertController also format a HTML-String? If yes, how?

Best regards

pmusolino commented 8 years ago

Hi @quiKsilverItaly, sorry for the delay.

You can use the attributed text property of the title or subtitle label. You can show some HTML using the attributed text like that (this code use Swift 2.0):

var attrStr = try! NSAttributedString( data: "<b><i>text</i></b>".dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: true)!, options: [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], documentAttributes: nil) label.attributedText = attrStr

Let me know. -Paolo

quiKsilverItaly commented 8 years ago

I used let alertVC = PMAlertController(title: "", description: "", image: nil, style: .Alert) alertVC.alertTitle.attributedText = attrStr to put attrStr into the PMAlertController. It works, thank you!