.underline()
Published Jan 23, 2023Updated Mar 2, 2023
Contribute to Docs
The .underline()
view modifier in SwiftUI applies an underline style to text characters in a View.
Syntax
Text("This text will be underlined")
.underline()
The .underline()
modifier is applied to all characters within the Text
(which conforms to the View
protocol).
Example
The following example creates some underlined text:
var body: some View {Text("Underlined text").underline()}
In the above example, the .underline()
modifier is called on the Text
view. This applies an underlined style to all characters within the Text
.
This will display the following:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn SwiftUI on Codecademy
- Skill path
Build iOS Apps with SwiftUI
Learn how to build iOS applications with Swift and SwiftUI and publish them to Apples' App Store.Includes 7 CoursesWith CertificateBeginner Friendly13 hours - Free course
Learn Swift
A powerful programming language developed by Apple for iOS, macOS, and more.Beginner Friendly12 hours