I'm new to SwiftUI and when I use the onChange modifier I get the following error.
Value of type 'some View' has no member 'onChange'
Here's the section of my code and if I remove line 9 - 26 my code will compile.
Value of type 'some View' has no member 'onChange'
Here's the section of my code and if I remove line 9 - 26 my code will compile.
Code Block GeometryReader{reader in VStack { Image("race2") .resizable() .aspectRatio(contentMode: .fill) .frame(width: UIScreen.main.bounds.width, height: reader.frame(in: .global).minY > 0 ? reader.frame(in: .global).minY + (UIScreen.main.bounds.height / 2.2) : UIScreen.main.bounds.height / 2.2) .offset(y: reader.frame(in: .global).minY) .onChange(of: reader.frame(in: .global).minY){value in let offset = value + ( UIScreen.main.bounds.height / 2.2) if offset < 80 { if offset > 0 { let opactity_value = (80 - opactity) / 80 self.opacity = Double(opactity_value) return } self.opacity = 1 } else { self.opacity = 0 } } } }