I'm getting different strings that occupy "busDescriptio" depending on what business you choose from a website database. This string contains html tags, images, and links. I was told to use NSAttributedString instead of UIWebView because UIWebView was giving me all sorts of problems such as images in wrong place, text font, and text color wouldn't fully work. I'm new to Swift so I cant really wrap my head around how NSAttributedString works. I was able to strip out the html tags and keep the font but that took away images, links, ext. with this
let encodedString = "\(busDescriptio)"
let encodedData = encodedString.dataUsingEncoding(NSUTF8StringEncoding)!
let attributedOptions = [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType]
let attributedString = NSAttributedString(data: encodedData, options: attributedOptions, documentAttributes: nil, error: nil)
let decodedString = attributedString?.string
and I loaded it into a UITextView
// Create UITextView
var textView = UITextView(frame: CGRectMake(0, 95.0, screenWidth-10, 300.0))
textView.text = decodedString
textView.font = UIFont.preferredFontForTextStyle(UIFontTextStyleBody)
border.addSubview(textView)
I dont like how any of this works so here is what I'm trying to do. - I wanting to change the font size, font color, and take in images with my string(busDescriptio). Do I use UIWebView to get this done or NSAttributedString? If so how can I do this?