From 70d757205b99b337f33909c9b89547f1c00a659f Mon Sep 17 00:00:00 2001 From: mlisivick Date: Tue, 25 Jul 2017 14:52:39 -0400 Subject: [PATCH] Add optional/default animation bool to provide non-animated index selection --- TwicketSegmentedControl/TwicketSegmentedControl.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/TwicketSegmentedControl/TwicketSegmentedControl.swift b/TwicketSegmentedControl/TwicketSegmentedControl.swift index 030f3b2..998e114 100644 --- a/TwicketSegmentedControl/TwicketSegmentedControl.swift +++ b/TwicketSegmentedControl/TwicketSegmentedControl.swift @@ -270,10 +270,13 @@ open class TwicketSegmentedControl: UIControl { delegate?.didSelect(index) } - open func move(to index: Int) { + open func move(to index: Int, animated:Bool? = true) { let correctOffset = center(at: index) - animate(to: correctOffset) - + if animated == true{ + animate(to: correctOffset) + }else{ + self.sliderView.center.x = correctOffset + } selectedSegmentIndex = index }