0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Jetpack ComposeとSwiftUIのSpacerの違い

Posted at

はじめに

今回は両OSで実装経験のあるフルスタックエンジニア視点でみたSpacerの違いを紹介していきます

本文

SwiftUIのSpacerは空気のクッションを配置しているイメージです。
逆にJetpackComposeは空箱を配置してるイメージが適していると思います。
SwiftUI の Spacerは下記の特徴を持ちます

  • 柔軟性が高い:空きスペースを「埋める」ように振る舞い、周囲のビューに応じてサイズが「自動調整」する
  • 空気入りクッションのような動きをし、隣接するビューのレイアウトによって伸びたり縮んだりする

Jetpack Compose の Spacerは下記の特徴を持ちます

  • 明示的な制御が必要:サイズや weight を明確に指定しない限り、ただの「透明な箱」で、柔軟な調整はしない
  • Modifier.weight() を使ったときに初めて「柔らかく膨らむ」ような動作をするが、それも Column/Row の Arrangement や他の要素の重みとの兼ね合いによります

最後に

一長一短が多くお互いいいところもあるのですが、Spacerに関しては圧倒的にSwiftUIのほうが好みです

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?