SimonFairbairn / SwiftyMarkdown

Converts Markdown files and strings into NSAttributedStrings with lots of customisation options.
MIT License
1.63k stars 269 forks source link

iOS 16 lines truncated when text contains multiple paragraphs. #131

Open tylerjames opened 2 years ago

tylerjames commented 2 years ago

Everything works fine prior to the iOS 16 betas.

If you have a string that contains multiple paragaphs all paragraphs after the first one will be truncated after the first line. This happens even if the markdown string passed to SwiftyMarkdown contains no special markdown formatting.

For example if passed some multi paragraph text it would render like this:

This is the first paragraph were text wraps properly and lines are not truncated. It can carry on for multiple lines just fine.

But every paragraph after the first will a its text trun....

And the third paragraph will appear truncated as we...

If you pass the exact same text as an NSAttributedString directly (not using SwiftyMarkdown) then it lays out correctly.

I'm not sure what is causing this as I don't quite understand the inner workings or how attributed strings are built. I don't know if Apple changed something behind the scenes here or if it's just a bug with the beta but it's probably worth looking into.

Thanks

Hank2354 commented 2 years ago

I have the same problem :name_badge: iOS 16

Inakitajes commented 1 year ago

Any update on this?

Temp workaround:

  1. Use UITextField instead of UILabel
  2. Use .sizeToFit() after setting the attributed string value if you want to wrap content.
Hank2354 commented 1 year ago

UITextView instead UILabel - also temp workaround