Post

Replies

Boosts

Views

Created

why is onAppear called twice on group in ZStack?
Is this a bug or why does "white" get printed to console twice but "black" only once in the below code? If I take out the Text() call then it works like I expect (both onAppear modifiers only called once).import SwiftUIstruct ContentView: View { var body: some View { ZStack { Group { Rectangle().fill(Color.black) } .onAppear() {print("black")} Group { Rectangle().fill(Color.white) Text("black on white").foregroundColor(.black) } .onAppear() { print("white")} } }}struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() }}
6
0
5.0k
Mar ’20