Last active
November 22, 2023 22:22
-
-
Save genedelisa/ebcc33c38a521ff8a719 to your computer and use it in GitHub Desktop.
Revisions
-
genedelisa revised this gist
Jan 25, 2017 . 1 changed file with 6 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,14 @@ /** Scroll to make the the given section header visible. The function scrollToItemAtIndexPath will scroll to the item and hide the section header. Swift 3. */ func scrollToSection(_ section:Int) { if let cv = self.collectionView { let indexPath = IndexPath(item: 1, section: section) if let attributes = cv.layoutAttributesForSupplementaryElement(ofKind: UICollectionElementKindSectionHeader, at: indexPath) { let topOfHeader = CGPoint(x: 0, y: attributes.frame.origin.y - cv.contentInset.top) cv.setContentOffset(topOfHeader, animated:true) } } -
genedelisa created this gist
May 27, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ /** Scroll to make the the given section header visible. The function scrollToItemAtIndexPath will scroll to the item and hide the section header. */ func scrollToSection(section:Int) { if let cv = self.collectionView { let indexPath = NSIndexPath(forItem: 1, inSection: section) if let attributes = cv.layoutAttributesForSupplementaryElementOfKind(UICollectionElementKindSectionHeader, atIndexPath: indexPath) { let topOfHeader = CGPointMake(0, attributes.frame.origin.y - cv.contentInset.top) cv.setContentOffset(topOfHeader, animated:true) } } }