2
3

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 3 years have passed since last update.

[SwiftUI] Textの省略位置の指定方法

Posted at

image.png

調べ方が悪くなかなか情報が見つからず、「SwiftUI Text Overflow」で調べてようやく見つかりました。文字溢れっていうんですね。

struct TestView: View {
    var body: some View {
        VStack{
            Text("SwiftUIでTextの省略位置を指定するにはtruncationModeを使用しましょう")
                .truncationMode(.tail)
                .lineLimit(1)
            Text("SwiftUIでTextの省略位置を指定するにはtruncationModeを使用しましょう")
                .truncationMode(.head)
                .lineLimit(1)
            Text("SwiftUIでTextの省略位置を指定するにはtruncationModeを使用しましょう")
                .truncationMode(.middle)
                .lineLimit(1)

        }
    }
}

このようにtruncationModeをセットすることで「……」にする位置を調整できます。

2
3
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
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?