LoginSignup
24
7

More than 3 years have passed since last update.

SwiftUIの.lineLimit()が効かない場合はfixedSize()

Posted at

2行以上にわたって表示させたいテキストがあったのですが、省略されてしまったので、改めてLineLimitを指定しました。

しかし、.lineLimit(nil) でも .lineLimit(100) でも効果がありませんでした。

Text(exchangeItem.name)
    .lineLimit(nil)
    .fixedSize(horizontal: false, vertical: true)

結論としては、上記のように.fixedSize(horizontal:vertical:)
を使用すれば良いみたいです。

今回は縦方向にテキストを行が増えるようにテキストを表示させたかったのでverticalをtrueにすると期待通り改行されて、省略されることなく表示されました😊

参考
https://stackoverflow.com/questions/56482955/adding-unlimited-lines-in-a-text-swiftui

24
7
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
24
7