Created
October 11, 2021 15:34
-
-
Save Akhu/6133748ce2f3251e299673ea91629ae7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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