Dmi*_*sev 5 uicontrol swift rx-swift rx-cocoa reactive
是否可以扩展结构 Reactive,其中基类是我从 UIControl 继承的自定义控件?
当我尝试以下代码时:
extension Reactive where Base: CustomControl {
public var value: ControlProperty<CGFloat> {
return CustomControl.rx.value(
self.base,
getter: { customControl in
customControl.customProperty
},
setter: { customControl, value in
customControl.customProperty = value
}
)
}
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
Instance member "value" cannot be used on type 'Reactive<CustomControl>'
Run Code Online (Sandbox Code Playgroud)
如果您向我提供任何解释,我将不胜感激。
小智 4
您可以检查此链接:https ://github.com/ReactiveX/RxSwift/issues/991
该方法value不是公开的,因此您需要创建该方法的公开版本。之后,就可以为您的自定义控件创建扩展。
| 归档时间: |
|
| 查看次数: |
2612 次 |
| 最近记录: |