Guest User

Untitled

a guest
Apr 25th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. private var expandedCell: ExpandableCell?
  2. private var isStatusBarHidden = false
  3.  
  4. override var prefersStatusBarHidden: Bool {
  5. return isStatusBarHidden
  6. }
  7.  
  8. // …
  9.  
  10. override func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
  11. if collectionView.contentOffset.y < 0 ||
  12. collectionView.contentOffset.y > collectionView.contentSize.height - collectionView.frame.height {
  13. return
  14. }
  15.  
  16. if let selectedCell = expandedCell {
  17. isStatusBarHidden = false
  18.  
  19. selectedCell.collapse()
  20.  
  21. collectionView.isScrollEnabled = true
  22.  
  23. expandedCell = nil
  24. } else {
  25. isStatusBarHidden = true
  26.  
  27. collectionView.isScrollEnabled = false
  28.  
  29. let selectedCell = collectionView.cellForItem(at: indexPath)! as! ExpandableCell
  30. selectedCell.expand(in: collectionView)
  31.  
  32. expandedCell = selectedCell
  33. }
  34.  
  35. self.setNeedsStatusBarAppearanceUpdate()
  36. }
Add Comment
Please, Sign In to add comment