ParagraphSpacing in swiftui

I have an NSMutableAttributedString that contains an NSMutableParagraphStyle, which sets the paragraphSpacing.

When I preview this in UIKit, everything displays correctly (paragraph spacing is applied). However, when I wrap this into an AttributedString, use it in a Text view (SwiftUI), the paragraphSpacing is ignored.

I looked into the documentation and noticed that AttributedString in SwiftUI does not yet support paragraphSpacing. For now, the only workaround I see is to keep this part in UIKit.

Has anyone found a way to make this work in SwiftUI?

Answered by DTS Engineer in 808394022

@petrykDima paragraphSpacing is currently not supported in SwiftUI. You are correct and the recommended workaround is to fallback to UIKit.

I’d suggest that you file a feedback report – If you do so, please share your report ID here for folks to track.

@petrykDima paragraphSpacing is currently not supported in SwiftUI. You are correct and the recommended workaround is to fallback to UIKit.

I’d suggest that you file a feedback report – If you do so, please share your report ID here for folks to track.

ParagraphSpacing in swiftui
 
 
Q