title: What are the correct dimensions for a custom tab bar item background image?
body: <p>So I have a <code>.png</code> that's 428x176 px:</p>
  
  <p><a href="https://i.stack.imgur.com/pF0vF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pF0vF.png" alt="enter image description here"></a></p>
  
  <p>I want to use it as a tab bar background image for when an item is in the selected state. The problem is that the image is too big. So now, I'm exploring the different resolution suffixes: @1x, @2x, @3x. But regardless of which I append to the image filename, the image remains too big for the tab bar item's background, although it does get smaller as I increase the resolution factor. How do I determine what the correct dimensions for this image should be?</p>
  
  <p>Keep in mind that this is a background image for when any particular <code>UITabBarItem</code> is in the selected state. It is meant to be the entire width and height of the <code>UITabBarItem</code>. My tab bar will have three items laid across the width of the screen.</p>
  
  <h2>Update:</h2>
  
  <p>A lot of answers are providing swift based solutions, but what I'm asking for is what dimensions my image should be in pixels, in other words, what sized images should I be including in my bundle, so that the image will fit in the tab bar at all screen sizes. I imagine that since a <code>UITabBar</code> by default expects a <code>UIImage</code> for its <code>selectionIndicatorImage</code> field and not a <code>UIImageView</code> that there must be a solution that doesn't involve hacking around the <code>UITabBar</code> and adding a <code>UIImageView</code> as a subview of it and managing what position the image view should be in, manually, based on which <code>UITabBarItem</code> is currently selected.</p>