SwiftUI – Right Align Text
To right align Text view in its frame, set the frame alignment of this Text view to trailing edge.
The following code shows how to right align text in Text view.
Text("Hello World")
.frame(maxWidth: .infinity, alignment: .trailing)
Example
In the following example, we created a Text view, and set its alignment to right, or trialing edge.
ContentView.swift
import SwiftUI
struct ContentView: View {
var body: some View {
VStack{
Text("Hello World")
.font(.title)
.fontWeight(.bold)
.frame(maxWidth: .infinity, alignment: .trailing)
.padding(.all)
.border(Color.gray.opacity(0.5))
}
.padding(.all)
}
}
Screenshot

Summary
Summarising this SwiftUI Tutorial, we learned how to right align text in Text view.