Skip to content

Data binding with swiftUI #382

@jjang8285

Description

@jjang8285

Description

I'm trying to set a property on a Rive animation instance right after binding, like this:

intro.riveModel?.enableAutoBind { instance in
  print("before:", instance.colorProperty(fromPath: "Icon BG")?.value)
  instance.colorProperty(fromPath: "Icon BG")?.value = .black
  print("after:", instance.colorProperty(fromPath: "Icon BG")?.value)
}

But the color doesn't actually update in the UI until I set it again later (e.g., in a button action):
instance?.colorProperty(fromPath: "Icon BG")?.value = .black
The binding is being done as part of .onAppear() and all the properties of the instance seem to be reset later once.
Also, I tried using non-auto binding and seeing the same issue.
Why does setting the color in enableAutoBind not immediately update the UI, but works when set again later?

Provide a Repro

Source .riv/.rev file

Expected behavior

Screenshots

Screenshot

Device & Versions (please complete the following information)

  • Device: [e.g. iOS Simulator, iPhone 12]
  • iOS version [e.g. iOS 15]

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions