Guest User

Untitled

a guest
Jun 22nd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. - (UICollectionViewLayoutAttributes *)layoutAttributesForSupplementaryViewOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath {
  2.  
  3. if (![kind isEqualToString:[myGridHeaderView kind]]) {
  4. return nil;
  5. }
  6.  
  7. myGridHeaderPosition headerPosition = [[self collectionView] headerPositionAtIndexPath:indexPath];
  8. CGRect cellRect = [[self delegate] getRectForHeaderAtIndex:indexPath headerPosition:headerPosition];
  9.  
  10. if (CGRectEqualToRect(cellRect, CGRectZero)) {
  11. return nil;
  12. }
  13.  
  14. myGridHeaderLayoutAttribute* attributes = [myGridHeaderLayoutAttribute layoutAttributesForSupplementaryViewOfKind:kind withIndexPath:indexPath];
  15.  
  16. CGPoint centerPoint = CGPointMake(CGRectGetMidX(cellRect), CGRectGetMidY(cellRect));
  17. CGSize size = cellRect.size;
  18.  
  19.  
  20. UICollectionView * const cv = self.collectionView;
  21.  
  22. NSInteger zIndex = 1;
  23. CGPoint const contentOffset = cv.contentOffset;
  24.  
  25. if (contentOffset.x > 0)
  26. {
  27. if (headerPosition != myGridHeaderPositionColumn)
  28. {
  29. centerPoint.x += contentOffset.x;
  30. }
  31. zIndex = 1005;
  32. }
  33. if (contentOffset.y > 0)
  34. {
  35. if (headerPosition != myGridHeaderPositionRow)
  36. {
  37. centerPoint.y += contentOffset.y;
  38. }
  39. zIndex = 1005;
  40. }
  41. if (headerPosition == myGridHeaderPositionCommon) {
  42. zIndex = 1024;
  43. }
  44. attributes.zIndex = zIndex;
  45. attributes.headerPosition = headerPosition;
  46. attributes.center = centerPoint;
  47. attributes.size = size;
  48. attributes.alpha = 1.0;
  49.  
  50. return attributes;
  51.  
  52. }
  53.  
  54. - (void)scrollViewDidScroll:(UIScrollView *)scrollView
  55. {
  56. isScrollingStart=YES;
  57. NSLog(@"scrollViewDidScroll %f , %f",scrollView.contentOffset.x,scrollView.contentOffset.y);
  58.  
  59.  
  60. if (scrollView.contentOffset.y<=124) {
  61. _img_top_header.alpha=scrollView.contentOffset.y/124;
  62. }
  63. else
  64. {
  65. _img_top_header.alpha=1.0;
  66. }
  67.  
  68.  
  69.  
  70. }
Add Comment
Please, Sign In to add comment