AMMeterView
AMMeterView
is a view can select value.
Demo
Usage
Create meterView.
let meterView = AMMeterView(frame: view.bounds)
// customize here
meterView.delegate = self
meterView.dataSource = self
view.addSubview(meterView)
Conform to the protocol in the class implementation.
/// DataSource
// Required
func numberOfValue(in meterView: AMMeterView) -> Int
func meterView(_ meterView: AMMeterView, titleForValueAtIndex index: Int) -> String
// Optional
func meterView(_ meterView: AMMeterView, textColorForValueAtIndex index: Int) -> UIColor // default is black
func meterView(_ meterView: AMMeterView, textFontForValueAtIndex index: Int) -> UIFont // default is System 15.0
/// Delegate
func meterView(_ meterView: AMMeterView, didSelectAtIndex index: Int) {
// use selected index here
}
Customization
AMMeterView
can be customized via the following properties.
@IBInspectable public var meterBorderLineWidth: CGFloat = 5
@IBInspectable public var valueIndexWidth: CGFloat = 2.0
@IBInspectable public var valueHandWidth: CGFloat = 3.0
@IBInspectable public var meterBorderLineColor: UIColor = .black
@IBInspectable public var meterColor: UIColor = .clear
@IBInspectable public var valueHandColor: UIColor = .red
@IBInspectable public var valueIndexColor: UIColor = .black
Installation
CocoaPods
Add this to your Podfile.
pod 'AMMeterView'
Carthage
Add this to your Cartfile.
github "adventam10/AMMeterView"
License
MIT