Not sure how to implement "Change the class of a view from UIView to CircularSlider"

110 Views Asked by At

I'm trying to use: http://cocoadocs.org/docsets/HGCircularSlider/2.0.0/index.html

Under the "Usage" section, the first step is : "Change the class of a view from UIView to CircularSlider, RangeCircularSlider or MidPointCircularSlider"

I'm not quite sure how to implement this. I've tried the following:

  1. My class:

    class TestView: UIView {
        override init (frame : CGRect) {
            super.init(frame : frame)
            let circularSlider = CircularSlider(frame: frame)
            circularSlider.minimumValue = 0.0
            circularSlider.maximumValue = 1.0
            circularSlider.endPointValue = 0.2
            addSubview(circularSlider)
        }
    
        convenience init () {
            self.init(frame:CGRect.zero)
        }
    
        required init(coder aDecoder: NSCoder) {
            fatalError("This class does not support NSCoding")
        }
    }
    
  2. In ViewCotroller, under "viewDidLoad":

    let circularSlider = CircularSlider(frame: frame)
    circularSlider.minimumValue = 0.0
    circularSlider.maximumValue = 1.0
    circularSlider.endPointValue = 0.2
    addSubview(circularSlider)
    

Both implementation does show the CircularSlider, but it obvious seems like it's broken. The movement of this circularSlider leaves permanent traces of the circles.

Maybe I'm not correctly implementing: "Change the class of a view from UIView to CircularSlider, RangeCircularSlider or MidPointCircularSlider"

0

There are 0 best solutions below