Open michael-martinez opened 6 years ago
Found one really inefficient but working solution : spb.removeAllAnimations() spb.removeFromSuperview() spb = nil
spb = SegmentedProgressBar(numberOfSegments: self.playerItems.count, durations: self.playerItemsDuration)
spb.frame = CGRect(x: 15, y: 15, width: view.frame.width - 30, height: 4)
view.addSubview(spb)
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.001) {
self.spb.startAnimation()
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.001) {
for _ in 0..<self.currentStory {
self.spb.skip()
}
}
Hello @michael-martinez are you using this with collection view ?
I found a solution. Add following code in SegmentedProgressBar class You can call segmentedProgressBarChangedIndex delegate if you want to notify.
func rewindCurrentSegment(){ let currentSegment = segments[currentAnimationIndex] currentSegment.topSegmentView.layer.removeAllAnimations() currentSegment.topSegmentView.frame.size.width = 0 self.animate(animationIndex: currentAnimationIndex) }
This is a simple project but very helpful. Easy to custome. Thanks dev team.
I am trying to load a previous story but cannot manage to do so.
Here is the function I am trying to implement which should be the opposite action to skip() :
func rewindOne() { let currentSegment = segments[currentAnimationIndex] currentSegment.topSegmentView.frame.size.width = 0 currentSegment.topSegmentView.layer.removeAllAnimations()
}
The animation does not stop, I have 3 items, tried: segments.forEach { $0.topSegmentView.layer.removeAllAnimations() } The segment keeps being animated.