
APFlipDigits is a SwiftUI package that lets you create an animated view capable of displaying numbers!
Inspiration came from this article
Default | Appearing Cells | Negative Number | Customization |
---|---|---|---|
![]() |
![]() |
![]() |
![]() |
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
)
)
}
}
You have to select File
-> Swift Packages
-> Add Package Dependency
and enter the repository url https://github.com/antoniopantaleo/APFlipDigits.git
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")),
],
//...
)