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

SwiftUIでハーフモーダルの高さを制限したい

Posted at

はじめに

今回はハーフモーダルの高さ制限をする方法を紹介していきます

本文

コード自体は下記になります。
実際に高さを制限しているのは presentationDetents()です。
ここで注意が必要なのはsheetに対してではなく内部のViewに対して生えていることです。
また、fractionは画面の割合をFloatで指定できるのですが、他にも.midiumなどといった用意された固定値や.heightにすることで直接指定することもできます。

.sheet(isPresented: $isShow) {
                VStack {
                }
                .presentationDetents([.fraction(0.2)])
            }

最後に

自分が実装した時に少し古めの記事が多く多少やり方が変わってるので記事にしました。
どなたかのお役に立てれば幸いです

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