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

Commit

Permalink
Improved keeping selected segment marked after switching style.
Browse files Browse the repository at this point in the history
  • Loading branch information
GocePetrovski committed Dec 14, 2016
1 parent 8f7828c commit 0ecbc7f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ScrollableSegmentedControl/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>0.9</string>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
4 changes: 3 additions & 1 deletion ScrollableSegmentedControl/ScrollableSegmentedControl.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public class ScrollableSegmentedControl: UIControl {
collectionView?.reloadData()

if indexPath != nil {
collectionView?.selectItem(at: indexPath, animated: true, scrollPosition: UICollectionViewScrollPosition.left)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05, execute: {
self.collectionView?.selectItem(at: indexPath, animated: true, scrollPosition: UICollectionViewScrollPosition.left)
})
}

}
Expand Down

0 comments on commit 0ecbc7f

Please sign in to comment.