2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【SwiftUI】Text内での改行を中央寄せ

Posted at

はじめに

⭕️
Simulator Screenshot - iPhone 14 - 2023-05-30 at 19.46.26.png Simulator Screenshot - iPhone 14 - 2023-05-30 at 19.47.08.png

実装

import SwiftUI

struct ContentView: View {
    var body: some View {
        Text("テストテキスト\nこれはテストテキストです")
+           .multilineTextAlignment(.center)
    }
}

おわり

同じ感じで右寄せもできます

import SwiftUI

struct ContentView: View {
    var body: some View {
        Text("テストテキスト\nこれはテストテキストです")
+           .multilineTextAlignment(.trailing)
    }
}
2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?