Skip to content

A SwiftUI package to display and animate integer numbers

License

Notifications You must be signed in to change notification settings

antoniopantaleo/APFlipDigits

Repository files navigation

APFlipDigits

Hero Image

APFlipDigits is a SwiftUI package that lets you create an animated view capable of displaying numbers!

Inspiration came from this article

Features

Default Appearing Cells Negative Number Customization
Hero Image Hero Image Hero Image Hero Image

Usage

Just instantiante a new FlipDigits view, specifying the number you want to display and, eventually, the minimum number of digits the view should display

import APFlipDigits
struct ContentView : View {

  @State private var number : Int = 100
  
  var body : some View {
    FlipDigits(number: $number, minNumberOfDigits: 3)
  }
}

You can customize the view specifying a FlipDigitsOptions, like in this example here:

import APFlipDigits
struct ContentView : View {

  @State private var number : Int = 100

  var body : some View {
    FlipDigits(
      number: $number,
      minNumberOfDigits: 3, 
      options:.init(
        cellSize: 70,
        cellSpacing: 0,
        cellColor: .blue,
        foregroundColor: .yellow
      )
    )
  }

}

Installation

Xcode Project

You have to select File -> Swift Packages -> Add Package Dependency and enter the repository url https://github.com/antoniopantaleo/APFlipDigits.git

Swift Package Manager

You have to add the package as a dependency in your Package.swift file

let package = Package(
    //...
    dependencies: [
        .package(url: "https://github.com/antoniopantaleo/APFlipDigits.git", upToNextMajor(from: "1.0.0")),
    ],
    //...
)

License

MIT