Semi transparent blur or frosted glass effect in SwiftUI

Created Sep 01 2020

SWIFT
1
import SwiftUI
2
3
struct Blur: UIViewRepresentable {
4
var effect: UIVisualEffect?
5
func makeUIView(context: UIViewRepresentableContext<Self>) -> UIVisualEffectView { UIVisualEffectView() }
6
func updateUIView(_ uiView: UIVisualEffectView, context: UIViewRepresentableContext<Self>) { uiView.effect = effect }
7
}
8
9
struct ContentView: View {
10
var body: some View {
11
ZStack {
12
Circle().fill(Color.orange).frame(width: 150, height: 150)
13
Blur(effect: UIBlurEffect(style: .light))
14
15
}.background(Color.white).frame(maxWidth: .infinity, maxHeight: .infinity)
16
}
17
}