Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for RxSwift. #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions SegmentedControl/Protocols.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,7 @@

import UIKit

public protocol SegmentedControlDelegate: class {
func segmentedControl(_ segmentedControl: SegmentedControl, didSelectIndex selectedIndex: Int)
func segmentedControl(_ segmentedControl: SegmentedControl, didLongPressIndex longPressIndex: Int)
}

public extension SegmentedControlDelegate {
func segmentedControl(_ segmentedControl: SegmentedControl, didSelectIndex selectedIndex: Int) {

}

func segmentedControl(_ segmentedControl: SegmentedControl, didLongPressIndex longPressIndex: Int) {

}
@objc public protocol SegmentedControlDelegate: NSObjectProtocol {
@objc optional func segmentedControl(_ segmentedControl: SegmentedControl, didSelectIndex selectedIndex: Int)
@objc optional func segmentedControl(_ segmentedControl: SegmentedControl, didLongPressIndex longPressIndex: Int)
}
4 changes: 2 additions & 2 deletions SegmentedControl/SegmentedControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ open class SegmentedControl: UIControl {
}

if 0..<segmentsCount() ~= touchIndex {
delegate?.segmentedControl(self, didSelectIndex: touchIndex)
delegate?.segmentedControl?(self, didSelectIndex: touchIndex)
if touchIndex != selectedIndex {
setSelected(at: touchIndex, animated: isAnimationEnabled)
}
Expand Down Expand Up @@ -419,7 +419,7 @@ extension SegmentedControl: UIGestureRecognizerDelegate {
return
}
if 0..<segmentsCount() ~= longPressIndex {
delegate?.segmentedControl(self, didLongPressIndex: longPressIndex)
delegate?.segmentedControl?(self, didLongPressIndex: longPressIndex)
}
}
}
Expand Down