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

SwiftUIでViewの背景をぼかす

4
Posted at

iOS15からbackgroundモディファイアを使って簡単に背景をぼかすことができたので、その紹介です。

ライトモードの場合 ダークモードの場合

やることはbackgroundモディファイアにぼかし度合いを設定するだけ。

Text(".ultraThinMaterial")
    .frame(width: 200, height: 100)
    .background(.ultraThinMaterial)  // 極薄のぼかし

こうすることで、表にくるView(上記の例ではText)と背景のViewの間にすりガラスのようなレイヤーが挟まり、ぼかし効果が得られます。

ぼかし度合いは上記のスクショの5種類の他にツールバーと同じぼかし効果を得る設定があります(この動作は未確認)。

参考URL:

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