Closed Tydewest closed 3 years ago
Ive only tried with swiftUI but should be the same as creating any other View programmatically. in SwiftUI you use UIRepresentable like this:
struct FuelGauge: UIViewRepresentable {
var percentage: Double
func makeUIView(context: Context) -> ABGaugeView {
let view = ABGaugeView(frame: .zero)
view.autoresizingMask = [.flexibleWidth, .flexibleHeight]
view.arcAngle = 1.8
view.applyShadow = false
view.isRoundCap = false
view.blinkAnimate = true
view.areas = "25,50,25" //Have to be String!
view.colorCodes = "FF2600,FFFB00,00F900"
view.backgroundColor = .gray
return view
}
func updateUIView(_ view: ABGaugeView, context: Context) {
view.needleValue = CGFloat(percentage*100)
}
}
Is It possible to create the gauge programatically