6
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 1 year has passed since last update.

【SwiftUI】いい感じのグラデーションを作成する

Last updated at Posted at 2023-05-31

はじめに

Appleの標準アプリのアイコンってシンプルなのにかっこいいですよね
かっこいい要因は背景にあるんではないかと思ってるんです。

AppStore Mail Message
IMG_3007.jpg IMG_3005.jpg IMG_3006.jpg

絶妙なグラデーションがかかってるんです
これをSwiftUIで再現する方法があったので記事にしておきます

実装

import SwiftUI

struct ContentView: View {
    var body: some View {
        RoundedRectangle(cornerRadius: 60)
+           .foregroundStyle(Color.blue.gradient.opacity(0.9))
            .frame(width: 300, height: 300)
    }
}

こんな簡単に微妙なグラデーションができました

simulator_screenshot_D941DF0E-9105-43E7-A278-302F0DD85F44.png

おわり

ちゃんとグラデーションを作りたい時はLinearGradientを使いましょう!

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