Home > AI > IOS > SwiftUI >

UIVisualEffectView

An object that implements some complex visual effects.

Example 1 (integrating with SwiftUI)

import SwiftUI

struct ContentView: View {

    var body: some View {
        ZStack {
            Image("poster")
                .resizable()
                .aspectRatio(contentMode: .fill)
                .frame(minWidth: 0, maxWidth: .infinity,
                       minHeight: 0, maxHeight: .infinity)
                .edgesIgnoringSafeArea(.all)
            
            Text("good")
                .frame(width: 200, height: 200)
                .background(BlurBG())
        }
        
    }
}




struct BlurBG : UIViewRepresentable {
    
    func makeUIView(context: Context) -> UIVisualEffectView{
        
        let view = UIVisualEffectView(effect: UIBlurEffect(style: .light))
        return view
    }
    
    func updateUIView(_ uiView: UIVisualEffectView, context: Context) {

    }
}

Leave a Reply