To run the example project, clone the repo, and run pod install
from the Example directory first.
iOS 13.0+
RadioColorPicker is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'RadioColorPicker'
If you are using rxswift, you can use delegate as Observable with the code below.
import UIKit
import RadioColorPicker
import RxSwift
import RxCocoa
class RxRadioColorPickerDelegateProxy: DelegateProxy<RadioColorPicker, RadioColorPickerDelegate>, DelegateProxyType, RadioColorPickerDelegate {
static func registerKnownImplementations() {
self.register { radioColorPicker -> RxRadioColorPickerDelegateProxy in
RxRadioColorPickerDelegateProxy(parentObject: radioColorPicker, delegateProxy: self)
}
}
static func currentDelegate(for object: RadioColorPicker) -> RadioColorPickerDelegate? {
return object.delegate
}
static func setCurrentDelegate(_ delegate: RadioColorPickerDelegate?, to object: RadioColorPicker) {
object.delegate = delegate
}
}
extension Reactive where Base: RadioColorPicker {
var delegate: RxRadioColorPickerDelegateProxy {
return RxRadioColorPickerDelegateProxy.proxy(for: self.base)
}
var selectedIndex: Observable<Int?> {
return delegate.sentMessage(#selector(RadioColorPickerDelegate.didItemSelected(index:color:)))
.map { value in
if let selectedIndex = value.first as? Int {
return selectedIndex
}
return nil
}
}
var selectedColor: Observable<UIColor?> {
return delegate.sentMessage(#selector(RadioColorPickerDelegate.didItemSelected(index:color:)))
.map { value in
if let selectedColor = value[1] as? UIColor {
return selectedColor
}
return nil
}
}
}
Wallaby, [email protected]
RadioColorPicker is available under the MIT license. See the LICENSE file for more info.