The successor to F3BarGauge

Overview

FDBarGauge

CI Status GitHub tag (latest SemVer) License

Screenshot

The successor to F3BarGauge

Background

This control is intended to replicate/simulate the level indicator on an audio mixing board. These indicators are usually segmented/stacked LEDs, with several colors to indicate thresholds. This control replicates that look, using Quartz drawing primitives, and auto-adjusts to horizontal or vertical orientation. Additionally, the colors, number of bars, peak hold, and other items are easily customized. Intended uses include:

  • Realtime data visualization
  • Level bars
  • Single-value charting
  • A VERY simple bar chart (if you use several of these)

Usage

Adding this control to your XCode project is straightforward:

  1. Add FDBarGauge to your project (File > Swift Packages > Add Package Dependency...)

  2. Add a new blank subview to your nib/storyboard, sized and positioned to match what the bar gauge should look like.

  3. In the properties inspector for this subview, change the class to "FDBarGauge"

  4. Below class, change the module to "FDBarGauge"

  5. Add an IBOutlet to your view controller

  6. Update your code to set the value property as appropriate.

For more information have a look at the demo code, which has multiple examples including a version that customizes the with an LCD-style appearance.

Following are all of the customizable properties:

/// Whether to maintain a view of local maximums
@IBInspectable public var holdPeak: Bool

/// This applies a gradient style to the rendering
@IBInspectable public var litEffect: Bool

/// If `true` then render top-to-bottom or right-to-left
@IBInspectable public var reverseDirection: Bool

/// The quantity to be rendered
@IBInspectable public var value: Double

/// The local maximum for `value`
@IBInspectable public var peakValue: Double

/// The highest possible amount for `value`
@IBInspectable public var maxLimit: Double

/// The lowest possible amount for `value`, must be less than `maxLimit`
@IBInspectable public var minLimit: Double

/// A quantity for `value` which will render in a special color
@IBInspectable public var warnThreshold: Double

/// A quantity for `value` which will render in a special color
@IBInspectable public var dangerThreshold: Double

/// The number of discrete segments to render
@IBInspectable public var numBars: Int

/// Outside border color
@IBInspectable public var outerBorderColor: UIColor

/// Inside border color
@IBInspectable public var innerBorderColor: UIColor

/// The rendered segment color before reaching the warning threshold
@IBInspectable public var normalColor: UIColor

/// The rendered segment color after reaching the warning threshold
@IBInspectable public var warningColor: UIColor

/// The rendered segment color after reaching the danger threshold
@IBInspectable public var dangerColor: UIColor

Installation

Use Swift Package Manager. In Xcode use: File > Swift Packages > Add Package Dependency…

License

Copyright (c) 2016 William Entriken

Copyright (c) 2011–2014 by Brad Benson

This is released under the MIT licence. Please see the file LICENSE for details.

Comments
  • Adopt layout from https://github.com/fulldecent/swift5-module-template

    Adopt layout from https://github.com/fulldecent/swift5-module-template

    A modern project layout for Swift modules is defined at https://github.com/fulldecent/swift5-module-template

    Work plan

    • [x] Study best practices at link above
    • [x] Apply the "Recipe" from the Swift 5 Module Template to this project
    • [x] Ensure that PR does not change the current development team

    Follow-on work

    • [x] Make a minor version feature release with this updated project
    opened by fulldecent 0
  • Deprecate old pod

    Deprecate old pod

    https://stackoverflow.com/questions/28789807/how-to-rename-a-cocoapod


    I can't get the new pod in because WTF. But once I do, get the old one deprecated.

    opened by fulldecent 0
  • Add quality testing to Travis

    Add quality testing to Travis

    See documentation at https://guides.cocoapods.org/making/quality-indexes.html and scoring at http://metrics.cocoapods.org/api/v1/pods/FDBarGuage

    See also https://cocoapods.org/pods/FDBarGuage/quality

    opened by fulldecent 0
  • Document release process

    Document release process

    Including

    • version bump
    • changelog // See format at https://github.com/CocoaPods/CocoaPods
    • tagging
    • CocoaPods push
    • carthage build

    Or maybe just make better commit like this https://github.com/CocoaPods/CocoaPods/commit/3832b47295ec889bd068d6224593b2776b125161

    https://github.com/Alamofire/Alamofire/blob/master/CHANGELOG.md

    opened by fulldecent 0
  • Bug

    Bug

    Hi, you have bug there, quite the opposite:

    if (!isnan(warnThreshold) && warnThreshold > 0.0) {
                    warningBarIdx = Int(warnThreshold * Double(numBars))
                } else {
                    warningBarIdx = -1
                }
    
    if (!isnan(dangerThreshold) && dangerThreshold > 0.0) {
                    dangerBarIdx = Int(dangerThreshold * Double(numBars))
                } else {
                    dangerBarIdx = -1
                }
    
    opened by maximator51 0
Releases(4.0.0)
Owner
William Entriken
EN/中文 [email protected]
William Entriken
Pilgrim - Dependency injection for Swift (iOS, OSX, Linux). Strongly typed, pure Swift successor to Typhoon.

pilgrim.ph Pilgrim is a dependency injection library for Swift with the following features: Minimal runtime-only library that works with pure Swift (s

AppsQuick.ly 60 Oct 24, 2022
Pilgrim is a pure Swift successor to Typhoon

Pilgrim is a pure Swift successor to Typhoon!! Typhoon uses the Objective-C runtime to collect metadata and instantiate objects. It powers thousands o

AppsQuick.ly 351 Nov 10, 2022