I'm trying to animate a view's alpha
property after I've sent it some values via a ReactiveSwift Signal Producer
.
The following is how I am currently doing it sans animations.
// Somewhere in View Model (for all code below)
let shouldShowShutter = MutableProperty<Bool>(false)
// In my View
self.shutterButton.reactive.alpha <~ self.viewModel.shouldShowShutter.map({ (show) -> CGFloat in
return show ? 1:0.0
})
I can inelegantly animate the view via:
self.viewModel.shouldShowShutter.producer.startWithSignal { (observer, disposable) in
observer.map({ (show) -> CGFloat in
return show ? 1:0.0
}).observeValues({ [unowned self] (alpha) in
UIView.animate(withDuration: 0.5, animations: {
self.shutterButton.alpha = alpha
})
})
}
But I should be able to animate the views with ReactiveAnimation
:
self.shutterButton.reactive.alpha <~ self.viewModel.shouldShowShutter.map({ (show) -> CGFloat in
return show ? 1:0.0
}).animateEach(duration: 0.2).join(.Concat)
The question: ReactiveCocoaLayout
and ReactiveAnimation
both don't seem to work anymore as of the time I am asking the question, at least not with the Swift 3 or ReactiveCocoa 5
as they depend a lot on the legacy RACSignals
.
Is there a more elegant way to animate signal streams to ReactiveCocoa components with ReactiveCocoa 5?