3
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-06-19

はじめに

UIを作っていると、シンプルすぎて物足りなさを感じることがあります。
この記事では、そんな時に簡単にワンランク上のUIにするテクニックを紹介します。

作るもの

Colorfulというライブラリを使って、動くグラデーションを作ります。

Colorfulとは

Colorfulは、簡単に動くグラデーションを作れるライブラリです。

デモ

準備

Swift Package ManagerでColorfulをインストールします。

使い方

基本的な使い方

import SwiftUI
import Colorful

struct ContentView: View {
     var body: some View {
        ColorfulView()
     }
}

たったこれだけで動くグラデーションができます。

色を指定する

ColorfulView(colors: [.blue, .purple, .pink])

colorsで色を指定できます。

その他の設定

ColorfulView(
    animated: Bool,
    animation: Animation,
    blurRadius: CGFloat,
    colors: [Color],
    colorCount: Int
)

おわりに

Colorfulを使うと簡単に動くグラデーションを作ることができます。
ぜひ使ってみてください。

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