Skip to content

Instantly share code, notes, and snippets.

@jacobsapps
jacobsapps / Haptics.swift
Created June 24, 2026 10:41
Haptics from My top 3 design “Kisses” I like to add to every app
func playAHAP(_ name: String) {
guard
let engine = try? CHHapticEngine(),
let url = Bundle.main.url(forResource: name, withExtension: "ahap")
else { return }
try? engine.start()
let player = try? engine.makePlayer(with: CHHapticPattern(contentsOf: url))
try? player.start(atTime: CHHapticTimeImmediate)
}
@jacobsapps
jacobsapps / Haptics.swift
Created June 24, 2026 10:41
Haptics from My top 3 design “Kisses” I like to add to every app
let event = CHHapticEvent(
eventType: .hapticContinuous,
parameters: [
CHHapticEventParameter(parameterID: .hapticIntensity, value: 1.0),
CHHapticEventParameter(parameterID: .hapticSharpness, value: 1.0),
],
relativeTime: 0,
duration: 60
)
@jacobsapps
jacobsapps / Grain.metal
Created June 24, 2026 10:41
Grain from My top 3 design “Kisses” I like to add to every app
#include <metal_stdlib>
using namespace metal;
[[ stitchable ]] half4 grain(float2 position, half4 color, float amount, float time) {
float noise = fract(sin(dot(floor(position), float2(12.9898, 78.233)) + time) * 43758.5453);
return half4(color.rgb + half3((noise - 0.5) * amount), color.a);
}
@jacobsapps
jacobsapps / ProgressiveBlurView.swift
Created June 24, 2026 10:13
ProgressiveBlurView from My top 3 design “Kisses” I like to add to every app
override func layoutSubviews() {
super.layoutSubviews()
let filter = (NSClassFromString("CAFilter") as! NSObject.Type)
.perform(NSSelectorFromString("filterWithType:"), with: "variableBlur")!
.takeUnretainedValue() as! NSObject
filter.setValue(20, forKey: "inputRadius")
filter.setValue(makeMaskImage(), forKey: "inputMaskImage")
filter.setValue(true, forKey: "inputNormalizeEdges")
@jacobsapps
jacobsapps / ProgressiveBlurView.swift
Created June 24, 2026 10:13
ProgressiveBlurView from My top 3 design “Kisses” I like to add to every app
private final class VariableBlurUIView: UIVisualEffectView {
override func layoutSubviews() {
super.layoutSubviews()
let filter = (NSClassFromString("CAFilter") as! NSObject.Type)
.perform(NSSelectorFromString("filterWithType:"), with: "variableBlur")!
.takeUnretainedValue() as! NSObject
filter.setValue(20, forKey: "inputRadius")
filter.setValue(makeMaskImage(), forKey: "inputMaskImage")
@jacobsapps
jacobsapps / ProgressiveBlurView.swift
Created June 24, 2026 10:13
ProgressiveBlurView from My top 3 design “Kisses” I like to add to every app
struct ProgressiveBlurView: UIViewRepresentable {
func makeUIView(context: Context) -> UIVisualEffectView {
VariableBlurUIView(effect: UIBlurEffect(style: .light))
}
func updateUIView(_ view: UIVisualEffectView, context: Context) {}
}
@jacobsapps
jacobsapps / ProgressiveBlurView.swift
Created June 24, 2026 10:13
ProgressiveBlurView from My top 3 design “Kisses” I like to add to every app
func makeUIView(context: Context) -> UIVisualEffectView {
let view = UIVisualEffectView(effect: UIBlurEffect(style: .light))
let filter = (NSClassFromString("CAFilter") as! NSObject.Type)
.perform(NSSelectorFromString("filterWithType:"), with: "variableBlur")!
.takeUnretainedValue() as! NSObject
filter.setValue(20, forKey: "inputRadius")
view.subviews.first?.layer.filters = [filter]
return view
}
@jacobsapps
jacobsapps / ProgressiveBlurView.swift
Created June 24, 2026 10:13
ProgressiveBlurView from My top 3 design “Kisses” I like to add to every app
struct ProgressiveBlurView: UIViewRepresentable {
func makeUIView(context: Context) -> UIVisualEffectView {
UIVisualEffectView(effect: UIBlurEffect(style: .light))
}
func updateUIView(_ view: UIVisualEffectView, context: Context) {
view.effect = UIBlurEffect(style: .light)
}
}
@jacobsapps
jacobsapps / ProgressiveBlurView.swift
Created June 24, 2026 10:13
ProgressiveBlurView from My top 3 design “Kisses” I like to add to every app
struct ProgressiveBlurView: UIViewRepresentable {
func makeUIView(context: Context) -> UIVisualEffectView {
UIVisualEffectView(effect: UIBlurEffect(style: .systemThinMaterialLight))
}
func updateUIView(_ view: UIVisualEffectView, context: Context) {
view.effect = UIBlurEffect(style: .systemThinMaterialLight)
}
}
@jacobsapps
jacobsapps / ContentView.swift
Created June 24, 2026 10:13
ContentView from My top 3 design “Kisses” I like to add to every app
var body: some View {
ScrollView {
// ...
}
.overlay(alignment: .top) {
Text("Design Kisses")
.font(.system(.headline, design: .rounded))
.frame(maxWidth: .infinity)
.padding(.vertical, 12)
.background {