How to Add Underline Text in iOS SwiftUI

In this blog post, we’re focusing on a commonly used tool for emphasizing content within an application – underlining text in SwiftUI. Whether it’s for accentuating headers, highlighting hyperlinks, or drawing attention to certain pieces of information, underlined text can significantly improve the user interface and experience.

Basics: Underlining Text

In SwiftUI, the .underline() modifier is used to underline text. It’s simple, straightforward, and efficient. Here’s an example:

Text("Hello, SwiftUI!")

In this example, the text “Hello, SwiftUI!” will be presented with an underline.

underline text in swiftui

Combine with Other Modifiers

The .underline() modifier can be combined with other SwiftUI text modifiers to create more personalized and dynamic text views:

Text("Hello, SwiftUI!")

In this example, the text “Hello, SwiftUI!” is underlined, bolded, and presented in blue color.

swiftui underlined text

Adding underlines to text in SwiftUI is an easy yet powerful way to emphasize and highlight content in your app. Its easy-to-use and composable nature still provides a host of possibilities for underlined text presentation.

Similar Posts

Leave a Reply