admin管理员组

文章数量:1291177

I am trying to give blur, opacity (0.8) with white color the the background of the Text so that when i scroll the content appear blured behind the text Container. I tried background(.ultraThinMaterial) but it has by default gray color and the requirment of blur with white color, and applied background(Color.white).opacity(0.8).blur(radius:) but this is applying background color to the blur

    var body: some View {
        
        ZStack {
            
                ScrollView{
                    Capsule()
                        .frame(width: 270,height: 120)
                        .padding(.top , 10)
                    Capsule()
                        .frame(width: 270,height: 120)
                        .padding(.top , 10)
                    Capsule()
                        .frame(width: 270,height: 120)
                        .padding(.top , 10)
                    VStack(alignment: .leading){
                        Text("Reach your goals faster by saving more every month")
                            .font(.system(size: 20))
                            .fontWeight(.bold)
                            .multilineTextAlignment(.center)
                            .padding()
                            .legoForegroundColor(tokens.semantic.color.brand.primary)
                        
                        Spacer()
                            .frame(height : 37)
                        
                        Text("My Active SIPs")
                            .font(.title3)
                            .bold()
                            .padding(.top , 10)
                        
                        ForEach(SipDetails, id: \.self){ SipDetail in
                            SipDetailsCardView(SipDetails: SipDetail)
                                //.background(Color.pink)
                                .cornerRadius(20)
                        }
                        
                    }
                }
                ZStack {
                    
                    VStack(spacing: 0) {
                        
                        HStack(alignment: .center) {
                            Text("this is example app")
                        }
                        .frame(maxWidth: .infinity)
                    }
                   // .readSize($viewHeight)
                }
            //    .background(Color.clear)
                .background(content: {
                    ZStack {
                        VisualEffectView(effect: UIBlurEffect(style: .systemUltraThinMaterialLight),
                                         blendingColor: UIColor.white.withAlphaComponent(0.8))
                    }
                })
                .frame(height: 56)
            
            .padding()
        }
        
    }

this is the implementation of VisualEffect and tried all the possible combination here as well but all of them applying opacity with white color not blur

struct VisualEffectView: UIViewRepresentable {
    
    var effect: UIVisualEffect
    var blendingColor: UIColor  // Blending color

    func makeUIView(context: UIViewRepresentableContext<Self>) -> UIVisualEffectView {
        let view = UIVisualEffectView(effect: UIBlurEffect(style: .systemUltraThinMaterialLight))
        view.backgroundColor = .clear
        view.contentView.backgroundColor = .clear//blendingColor
        view.contentView.alpha = 0.8

        return view
    }

    func updateUIView(_ uiView: UIVisualEffectView,
                      context: UIViewRepresentableContext<Self>) {
        uiView.effect = effect
        uiView.backgroundColor = blendingColor
    }
    
}

本文标签: swiftstrugle to get bluropacity all with white Backgroundcolor in swiftUIStack Overflow