Skip to content

Instantly share code, notes, and snippets.

@Akhu
Created October 11, 2021 15:34
Show Gist options
  • Save Akhu/6133748ce2f3251e299673ea91629ae7 to your computer and use it in GitHub Desktop.
Save Akhu/6133748ce2f3251e299673ea91629ae7 to your computer and use it in GitHub Desktop.
//
// BindingBlurSampleView.swift
// InstaFilter
// Credit to Paul Hudson
// Created by Anthony Da cruz on 05/10/2021.
//
import SwiftUI
struct BindingBlurSampleView: View {
@State var blurAmount: CGFloat = 0
var body: some View {
let blur = Binding<CGFloat>(
get: {
self.blurAmount
}, set: {
self.blurAmount = $0
print("New value is \(self.blurAmount)")
}
)
return VStack {
Text("Hello, World!")
.blur(radius: blurAmount)
Slider(value: blur, in: 0...20)
}
}
}
struct BindingBlurSampleView_Previews: PreviewProvider {
static var previews: some View {
BindingBlurSampleView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment