Closed khoren93 closed 7 years ago
Hi @khoren93,
I am really happy that you like it :)
With the next release that I am planning to publish soon, I will expose a property that you will be able to use to set the selected segment programatically.
Unfortunately, currently it is not possible to have the index set to -1, i.e. not to have any selected segment. However, I like your suggestion and I will try to implement this one in the next release as well.
Cheers, Sasho
Hi @khoren93,
I just wanted to give you an update regarding your requested feature :)
I have just published a new version of the library (v. 1.1.0) in which I have exposed a property and a method for setting the current segment.
You can use the currentSegment
property to set the currently selected segment to a different index that ranges from 0
to segmentsCount-1
. You should set this property in the viewDidAppear(_:)
method because at this point all subviews of the segmented control have been created. By setting this property, the segment will change without an animation.
If you need to change the segment programmatically with an animation, you can call the setCurrentSegmentIndex(_:animated:)
method and pass in a bool
for the animated
parameter.
I hope that this answers your question and satisfies your needs :)
Cheers!
Hi, thanks for great lib :) I have a few questions. Is it possible to change the selected segment programmatically, and if yes, how can I do that?
And my second question is: is it possible not to have any index selected at all? Say, set the index to -1?
Thanks