0

What would be the best way to display long passage with rich text style(multiple font styles, color, image).

Attached screen is similar to the kind of content I need to display.

enter image description here

6
  • What's wrong with UITextView? It gives you the full Text Kit engine; that's as fast, powerful, and full-featured as it gets on Mac or iOS. Commented Feb 3, 2018 at 22:59
  • 1
    How can we show the image, text with multiple fonts and styles? We could use attributedString for this but content size is too long(30 pages) Commented Feb 3, 2018 at 23:02
  • 1
    @Fattie, I do have other solution like use DTCoreText(github.com/Cocoanetics/DTCoreText) kind of thing but for this, I have to restructure content again into HTML and display it, it will not lag in performance as well. I fear to create HTML for all content, not sure if it is the best solution. Commented Feb 3, 2018 at 23:14
  • 1
    "We could use attributedString for this but content size is too long(30 pages)" I don't know why you say it's too long. You could lay it all out with PDF Kit if you want to paginate. Commented Feb 3, 2018 at 23:35
  • 1
    @matt PDF is another option but again need to create formatted PDF. Commented Feb 4, 2018 at 7:41

1 Answer 1

2

The by far easiest approach is to convert your rich text to HTML and use a UIWebView to display it. The web view will take care of so many things:

  • formatting
  • scrolling
  • loading fonts asynchronously
  • loading images asynchronously
Sign up to request clarification or add additional context in comments.

9 Comments

Good luck in finding an alternative that is sufficiently powerful and faster.
hi @SantoshSingh - this is the correct answer. You "shouldn't be" displaying crap like this in an app. if you have to do so - use a UIWebView!
Agreed, but as per my customer requirement, they have to display the long list of pages. There are many apps which use the long passage to display.
@Fattie Maybe UIWebView or they would have used NSAtttribuedString from HTML content for rendering. Isn't? NSAttributedString(data: self, options: [.documentType: NSAttributedString.DocumentType.html, .characterEncoding: String.Encoding.utf8.rawValue], documentAttributes: nil)
actually @SantoshSingh you may want to review this stackoverflow.com/questions/43723345 very complicayed and annoying issue! just FYI
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.