How to set Text to Italic in SwiftUI?

SwiftUI – Italic Text

To make the text italic in Text view, call italic() method on this Text view. italic() method applies italics to the text in this Text view.

Example

In the following example, we created a Text view, and called italic() method on the Text view.

ContentView.swift

import SwiftUI

struct ContentView: View {
    var body: some View {
        Text("Hello, world!")
            .italic()
    }
}

Screenshot

Text view – Italic text

Summary

Summarising this SwiftUI Tutorial, we learned how to apply italics to the text in Text view.