Skip to content

Instantly share code, notes, and snippets.

@douglastaquary
Created February 23, 2017 20:33
Show Gist options
  • Select an option

  • Save douglastaquary/146805220b886122c2026e5a16224794 to your computer and use it in GitHub Desktop.

Select an option

Save douglastaquary/146805220b886122c2026e5a16224794 to your computer and use it in GitHub Desktop.
func scrollToSection(_ section: Int) {
let numbersOfBehaviors = items[section].behaviors?.count
if let cv = self.collectionView {
let indexPath = IndexPath.init(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)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment