title: Custom Tab Bar Background Image is not showing correctly
body: <p>I'm implementing a custom Tab bar for my iOS app. Im using the following code to display a background image:</p>
  <pre><code> class TabNavigationMenu: UIView {
   // ...
   // ...
      UIGraphicsBeginImageContext(self.frame.size)
      UIImage(named: &quot;tabBarbg.png&quot;)?.draw(in: self.bounds)
      let image = UIGraphicsGetImageFromCurrentImageContext()
      UIGraphicsEndImageContext()
  
      if let image = image {
          self.backgroundColor = UIColor(patternImage: image)
      }
   }
  </code></pre>
  <p>However, the tab bar is presented like this:</p>
  <p><a href="https://i.stack.imgur.com/Mmaan.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mmaan.png" alt="enter image description here" /></a></p>
  <p>Also, when i make a view and present it anywhere else in the screen, it displays correctly. I'm using the same code there as well. Heres an example:</p>
  <p><a href="https://i.stack.imgur.com/1IH70.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1IH70.png" alt="enter image description here" /></a></p>
  <p>Any idea what the problem could be? I'm guessing the solution would also solve the faint blue line on top of the view...</p>