title: UIView that follows UICollectionView indicator
body: <p>I want to create a custom UIView that contains a UIImageView and a UILabel, that points to the UICollectionView scroll indicator, and scrolls with it.</p>
  
  <p><a href="https://i.stack.imgur.com/MSak5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MSak5.png" alt="enter image description here"></a></p>
  
  <p>i am using this code :</p>
  
  <pre><code>- (void)scrollViewDidScroll:(UIScrollView *)scrollView
  {
      //get refrence of vertical indicator
      UIImageView *verticalIndicator = ((UIImageView *)[scrollView.subviews objectAtIndex:(scrollView.subviews.count-1)]);
      // get the relative position of the indicator in the main window
      CGPoint p = [verticalIndicator convertPoint:verticalIndicator.bounds.origin toView:[[UIApplication sharedApplication] keyWindow]];
      // set the custom view new position
      CGRect indicatorFrame = self.indicatorView.frame;
      indicatorFrame.origin.y = p.y;
      self.indicatorView.frame = indicatorFrame;
  }
  </code></pre>
  
  <p>But the indicatorView does not follow the indicator exactly !!</p>