FlickerNumber Swift
FlickerNumber Swift is a lightweight and customizable library that provides an animated number counting effect for iOS applications. With FlickerNumber Swift, you can easily create a visually appealing and interactive counter for displaying statistics, timers, scores, or any numeric value.
Key Features
- Smooth and animated number counting effect
- Supports both integer and decimal numbers
- Customizable number formatting
- Configurable duration and animation style
- Easy integration with any iOS project
Installation
To integrate FlickerNumber Swift into your project, you can use CocoaPods or manually add the library files to your project.
Using CocoaPods
You can install FlickerNumber Swift through CocoaPods by adding it to your Podfile
:
pod 'FlickerNumberSwift'
Don’t forget to run pod install
after updating your Podfile
.
Manual Installation
- Download the latest release of FlickerNumber Swift from the GitHub repository.
- Copy the
FlickerNumber.swift
file and add it to your Xcode project. - Make sure to include the file in your target’s build phase.
Usage
Using FlickerNumber Swift is simple and straightforward. Follow these steps to add a flickering number counter to your project:
- Import the FlickerNumber Swift module in your Swift file:
import FlickerNumberSwift
- Create an instance of
FlickerNumberLabel
and add it to your view hierarchy. - Set the initial value and format of the number label:
// Example usage with integer number let numberLabel = FlickerNumberLabel(frame: CGRect(x: 0, y: 0, width: 200, height: 80)) numberLabel.set(number: 1234) numberLabel.format = "%.0f" // No decimal places // Example usage with decimal number let decimalLabel = FlickerNumberLabel(frame: CGRect(x: 0, y: 0, width: 200, height: 80)) decimalLabel.set(number: 12.345) decimalLabel.format = "%.2f" // Two decimal places
- Optionally, customize the appearance and animation properties:
// Customize appearance numberLabel.font = UIFont.systemFont(ofSize: 40) numberLabel.textColor = UIColor.red numberLabel.textAlignment = .center // Customize animation numberLabel.duration = 1.5 // Duration of the counting animation numberLabel.animationStyle = .easeInOut
Example
Here’s a simple example that demonstrates the usage of FlickerNumber Swift:
// Import FlickerNumber Swift
import FlickerNumberSwift
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Create a FlickerNumberLabel instance
let numberLabel = FlickerNumberLabel(frame: CGRect(x: 0, y: 0, width: 200, height: 80))
numberLabel.center = view.center
// Customize appearance
numberLabel.font = UIFont.systemFont(ofSize: 40)
numberLabel.textColor = UIColor.red
numberLabel.textAlignment = .center
// Set initial value and format
numberLabel.set(number: 0)
numberLabel.format = "%.0f"
// Customize animation
numberLabel.duration = 1.5
numberLabel.animationStyle = .easeInOut
// Add the number label to the view
view.addSubview(numberLabel)
// Start counting animation
numberLabel.count(from: 0, to: 1000)
}
}
Conclusion
Congratulations! You’ve successfully integrated FlickerNumber Swift into your project. Now you can easily add animated number counting effects with customization options, making your iOS app more visually engaging and interactive.
For more details and advanced usage, you can check out the official GitHub repository or the CocoaDocs documentation.