100 Days of SwiftUI

Day 66

2026-07-19

Project 13, part 5

Finishing up the basic app

Customizing our filter using confirmationDialog()

Here are the filters we’re offering

Button("Crystallize") { setFilter(CIFilter.crystallize()) }
Button("Edges") { setFilter(CIFilter.edges()) }
Button("Gaussian Blur") { setFilter(CIFilter.gaussianBlur()) }
Button("Pixellate") { setFilter(CIFilter.pixellate()) }
Button("Sepia Tone") { setFilter(CIFilter.sepiaTone()) }
Button("Unsharp Mask") { setFilter(CIFilter.unsharpMask()) }
Button("Vignette") { setFilter(CIFilter.vignette()) }

Because they have different ways of describing “how much” (Intensity, Radius, Scale) you have to do some machinations in the processing step, e.g.

let inputKeys = currentFilter.inputKeys

if inputKeys.contains(kCIInputIntensityKey) {
    currentFilter.setValue(
        filterIntensity,
        forKey: kCIInputIntensityKey
    )
}
if inputKeys.contains(kCIInputRadiusKey) {
    currentFilter.setValue(
        filterIntensity * 200,
        forKey: kCIInputRadiusKey
    )
}
if inputKeys.contains(kCIInputScaleKey) {
    currentFilter.setValue(
        filterIntensity * 10,
        forKey: kCIInputScaleKey
    )
}

A simple slider like we’re using doesn’t really give a lot of control, but really, too many dials means too much confusion.

I am wondering why it’s a series of if statements. Would Switch be better?

Also at the moment there is no way to combine filters…