Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for index = UISegmentedControl.noSegment #125

Closed
wants to merge 1 commit into from

Conversation

fredriks
Copy link

First of all, thanks for a great package!

This is a quick fix that allows index to be set to UISegmentedControl.noSegment.

Whenever thats the case we hide the indicatorView. We also disable animations for going from or to noSegment.

Fixes #88, fixes #37 and fixes #10

Thanks again!

@UtkuDalmaz
Copy link

UtkuDalmaz commented Feb 6, 2020

I tried segmentCtrl.setIndex(UISegmentedControl.noSegment) but it still has selected index? @fredriks @gmarm

@fredriks
Copy link
Author

fredriks commented Feb 6, 2020

@UtkuDalmaz how did you import the library?

@UtkuDalmaz
Copy link

@UtkuDalmaz how did you import the library?

I copied your version and pasted to pods files on my project

@fredriks
Copy link
Author

fredriks commented Feb 6, 2020

Cool, sound like that should work! Though could you try using the pending PR via my fork to confirm its not an issue with the copy-paste?

pod 'BetterSegmentedControl',
    :git => 'https://github.com/fredriks/BetterSegmentedControl',
    :tag => '1.3.0-nosegment'

@UtkuDalmaz
Copy link

Cool, sound like that should work! Though could you try using the pending PR via my fork to confirm its not an issue with the copy-paste?

pod 'BetterSegmentedControl',
    :git => 'https://github.com/fredriks/BetterSegmentedControl',
    :tag => '1.3.0-nosegment'

I updated with your pod but it still has a selected index

segmentCtrl2.segments = LabelSegment.segments(withTitles: ["18:00 - 19:00","19:00 - 20:00", "20:00 - 21:00", "21:00 - 22:00"],numberOfLines:2,normalFont: UIFont(name: "HelveticaNeue-Light", size: 14.0)!,
        normalTextColor: .lightGray,
        selectedFont: UIFont(name: "HelveticaNeue-Bold", size: 14.0)!,
        selectedTextColor: .white)

        segmentCtrl2.setIndex(UISegmentedControl.noSegment)

        segmentCtrl2.addTarget(self, action: #selector(SubscribedUser.updateGarbage), for: .valueChanged)

here is my code on viewDidLoad

@fredriks
Copy link
Author

fredriks commented Feb 6, 2020

Dude, you are fast! Did you have time to run pod install? 😅

I did a test with a simple setup based on the code you provided and it works fine here.

@UtkuDalmaz
Copy link

After erase & reset simulator and restarting xcode it now works :)

@gmarm
Copy link
Owner

gmarm commented Oct 21, 2020

Support for no selected segmented was added in #142.

Thanks for opening this!

@gmarm gmarm closed this Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot Accept UISegmentedControl.noSegment selectedSegmentIndex -1 Allow control to be deselected
3 participants