6

I would like to observe changes to @Binding property in subview. But there didSet/willSet is not called (it is called only if I change this variable from current view, but if change is from outside view then this handlers are not executed)

I want to execute some code when

 @Binding var selectedElement: Int

is changed from parent view.

Then I want to recalculate xOffset state property

 @State var xOffset: CGFloat = 0

The calculation should increment current xOffset value like:

self.xOffset += self.contentSize.width/2 - (self.rects[i].minX + self.rects[i].width/2)

But I stack in this place.

Michał Ziobro
  • 10,759
  • 11
  • 88
  • 143

0 Answers0