TTBaseUIProgressView
CoreEnhanced UIProgressView subclass with auto-incrementing tick animation (simulates indeterminate progress), configurable tick speed via periodValue, themed colors from ViewConfig, and simple onStart() / onFinished() lifecycle API.
Note: For a full-featured SwiftUI progress indicator (LINEAR, CIRCULAR, INDETERMINATE), see TTBaseSUIProgressView. The UIKit version is ideal for navigation bar loading indicators or simple progress feedback.
🚀 Usage
Basic Indeterminate Loader
let progressBar = TTBaseUIProgressView()
// Add to view (often in navigation bar or below header)
view.addSubview(progressBar)
progressBar.setLeadingAnchor(constant: 0)
.setTrailingAnchor(view, constant: 0, priority: .required)
.setTopAnchor(constant: 0).done()
progressBar.setHeightAnchor(constant: 3)
// Start auto-increment animation
progressBar.onStart()
// Complete with a fill-to-100% animation
progressBar.onFinished()
API Call Loading Indicator
class ProductVC: TTBaseUIViewController {
lazy var progressBar = TTBaseUIProgressView()
override func setupConstraints() {
progressBar.setLeadingAnchor(constant: 0)
.setTopAnchor(constant: 0)
.setTrailingAnchor(self.view, constant: 0, priority: .required)
.done()
progressBar.setHeightAnchor(constant: 2)
}
func loadProducts() {
progressBar.isHidden = false
progressBar.onStart()
APIService.fetchProducts { [weak self] result in
self?.progressBar.onFinished()
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
self?.progressBar.isHidden = true
}
}
}
}
Deterministic Progress (native UIProgressView)
// For exact progress values, use UIProgressView directly
// TTBaseUIProgressView auto-ticks — use setProgress() for manual control
progressBar.setProgress(0.75, animated: true)
progressBar.onFinished() // Animate to 1.0 then stop timer
Subclass to Customize
class FastProgressBar: TTBaseUIProgressView {
// Larger tick increment = faster visual animation
override var periodValue: Float { 0.01 }
}
📖 API Reference
| Method / Property | Type | Description |
|---|---|---|
periodValue | Float | Increment per tick (default: 0.004). Override to control speed. |
onStart() | Void | Reset to 0 and begin auto-tick timer (every 0.04s) |
onFinished() | Void | Animate fill to 1.0, then invalidate timer |
⚙️ Theme Colors
// Colors come from ViewConfig
TTBaseUIKitConfig
.withDefaultConfig()
.withViewConfig(
TTBaseUIKitViewConfig(
processViewBgColor: .systemGray6, // Bar background
processViewProcessColor: .systemBlue, // Progress fill color
processViewTrackColor: .systemGray5 // Track color
)
)
.start()