Skip to content

Numbers not animating when used in UIKit #4

Description

@rubnov

First off, thank you for this repo!

I'm trying to embed MovingNumbersView in UIKit using UIHostingControlller. However, the numbers are not animating as shown in your README video snippets. Here is my code excerpt:

        let randomInt = Double.random(in: 0..<10000000)
        let value : Double = PSUnitConversion.localizedDistance(fromMeters: randomInt)
        
        let vc = UIHostingController(rootView: MovingNumbersView(number: value, numberOfDecimalPlaces: 1) { str in
            Text(str).font(.largeTitle)
        })
        if let subview = vc.view {
            subview.translatesAutoresizingMaskIntoConstraints = false
            addChild(vc)
            view.addSubview(subview)
            NSLayoutConstraint.activate([
                subview.centerXAnchor.constraint(equalTo: view.centerXAnchor),
                subview.centerYAnchor.constraint(equalTo: view.centerYAnchor),
            ])
            vc.didMove(toParent: self)
        }

The MovingNumbersView appears on the screen, but the numbers are not animating.

I also couldn't find any way to "update" the MovingNumbersView, i.e. to animate from one set of numbers to another. Can this be done?

Finally, is there an example project that shows how to use MovingNumbersView within UIKit?

thank you for your help!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions