はじめに
SwiftUIのcolorMultiply
という機能でカラーフィルター的なことができたので記事にしておきます
サンプルアプリ
実装
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)
}
}
おわり
いい感じにできました!