title: Custom focus engine behaviour for UICollectionView
body: <p>I use a standard <code>UICollectionView</code> with sections. My cells are laid out like a grid. The next cell in a chosen direction is correctly focused if the user moves the focus around with the Apple TV remote. But if there is a "gap" in the grid, the default focus engine jumps over sections. It does this to focus a cell which could be several sections away but is in the same column.</p>
  
  <p>Simple Example:
  There are 3 sections. The first section has 3 cells. The second has 2 cells and the last one has 3 cells again. See the following image:</p>
  
  <p><a href="https://i.stack.imgur.com/ums8b.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ums8b.png" alt="enter image description here"></a></p>
  
  <p>If the green cell is focused and the user touches the down direction, the yellow cell gets focused and section two is skipped by the focus engine. </p>
  
  <p>I would like to force it that no sections can get jumped over. So instead of focusing the yellow cell I would like to focus the blue cell.</p>
  
  <p>I learned that the Apple TV Focus engine internally works like a grid system and that the described behaviour is the default one. To allow other movements (e.g. diagonal) we need to help the focus engine by placing invisible  <code>UIFocusGuide</code>s which can redirect the focus engine to a <code>preferredFocusedView</code>. </p>
  
  <p>So in the following image there is one invisible red focus guide placed into the empty space of a <code>UICollectionView</code> section which would redirect the down focus to the desired blue cell. I think that would be the perfect solution, in theorie. </p>
  
  <p><a href="https://i.stack.imgur.com/uxpZz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/uxpZz.png" alt="enter image description here"></a></p>
  
  <p>But how would I add <code>UIFocusGuide</code>s to all empty spaces of <code>UICollectionView</code> sections? I have tried several things but nothing worked. Maybe add it as a Decorator View but that seems wrong. Or as additional cells, but that breaks the data layer and the constraints anchors do not work.</p>
  
  <p>Has anyone an idea on how to add <code>UIFocusGuide</code>s to a <code>UICollectionView</code>?</p>