Skip to content
This repository was archived by the owner on Apr 11, 2021. It is now read-only.

Commit 63fa783

Browse files
committed
Fixed issues with selectedSegmentIndex not been respected when set in viewDidLoad.
1 parent cdceb3e commit 63fa783

3 files changed

Lines changed: 4 additions & 3 deletions

File tree

Demo/ScrollableSegmentedControlDemo/ScrollableSegmentedControlDemo/TableViewController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class TableViewController: UITableViewController {
2828
segmentedControl.insertSegment(withTitle: "Segment 6", image: #imageLiteral(resourceName: "segment-6"), at: 5)
2929

3030
segmentedControl.underlineSelected = true
31+
segmentedControl.selectedSegmentIndex = 0
3132

3233
segmentedControl.addTarget(self, action: #selector(TableViewController.segmentSelected(sender:)), for: .valueChanged)
3334
}

ScrollableSegmentedControl/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.0</string>
18+
<string>1.0.1</string>
1919
<key>CFBundleVersion</key>
2020
<string>$(CURRENT_PROJECT_VERSION)</string>
2121
<key>NSPrincipalClass</key>

ScrollableSegmentedControl/ScrollableSegmentedControl.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,8 @@ public class ScrollableSegmentedControl: UIControl {
350350
underlineView?.removeFromSuperview()
351351
} else {
352352
underlineView = UIView()
353-
underlineView?.backgroundColor = tintColor
354-
underlineView?.isHidden = true
353+
underlineView!.backgroundColor = tintColor
354+
underlineView!.isHidden = !isSelected
355355
contentView.insertSubview(underlineView!, at: contentView.subviews.count)
356356
}
357357

0 commit comments

Comments
 (0)