Open amajeedmuazu opened 7 years ago
Need some help here! Author, please =)
Here is how I had accomplished this task...
public protocol SWSegmentedControlDelegate {
func segmentControl(_segmentControl: SWSegmentedControl, didSelectSegmentAt index: Int)
}
public var delegate: SWSegmentedControlDelegate!
didTapButton(_ button: UIButton)
:
self.delegate?.segmentControl(_segmentControl: self, didSelectSegmentAt: self.selectedSegmentIndex)
extension YourObject: SWSegmentedControlDelegate {
func segmentControl(_segmentControl: SWSegmentedControl, didSelectSegmentAt index: Int) {
// do things
}
}
var segmentedControl: SWSegmentedControl {
let sc = SWSegmentedControl(items: ["item1", "item2"])
sc.delegate = self
return sc
}
How to set delegate or selection changed method?