3
2

More than 1 year has passed since last update.

はじめに

SwiftUIのcolorMultiplyという機能でカラーフィルター的なことができたので記事にしておきます

サンプルアプリ

Simulator Screen Recording - iPhone 14 Pro - 2023-07-18 at 22.02.28.gif

実装

import SwiftUI

struct ContentView: View {
    @State private var color: Color = .red
    
    var body: some View {
        VStack(spacing: 50) {
            Image("sample")
                .resizable()
                .aspectRatio(contentMode: .fit)
                .colorMultiply(color)
                .frame(maxWidth: .infinity)
            
            ColorPicker("カラーフィルター", selection: $color)
        }
        .padding(.horizontal, 20)
    }
}

おわり

いい感じにできました!

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