2021年1月29日星期五

How can I access to inaccessible contents of a View for some modification in SwiftUI?

I am getting delivered a finished View from some part of my app, and I need to make some modifications which requires direct access to that View inside, which I do not have that access, How could I solve this problem in proper way?

For example in CircleView() I can use simple opacity modify and make this down View:

enter image description here

But some how I am getting this down View "I purposely making this View to find an Answer and this is only an Example", How can I make opacity modification to this View or to this Circles to getting same result like up View?

enter image description here

Also I Know that I can play with overly and gradient to reaching almost same result, But as I said I looking for a proper way for this, I got some idea like playing around with PreferenceKey or maybe GeometryReader-global , .. . But all are just idea I am unable to solve this issue alone, and I need help. all we got to start to working is CircleView().

    struct ContentView: View {      var body: some View {                      ZStack {                            Color.yellow.ignoresSafeArea()                            CircleView()                        }          }  }  

  struct CircleView: View {        var body: some View {                    VStack {                ForEach(1..<11, id:\.self) { index in                                    Circle()                      .fill()                      //.opacity(Double(index)/10)                      .frame(width: 50, height: 50, alignment: .center)                }            }                }        }  
https://stackoverflow.com/questions/65964233/how-can-i-access-to-inaccessible-contents-of-a-view-for-some-modification-in-swi January 30, 2021 at 11:02AM

没有评论:

发表评论