title: Setting Navigation bar back button Image for entire application in swift
body: <p>I am setting navigation bar back button in <code>AddDelegate</code> but it is not setting properly.</p>
  
  <p>I have tried below code :</p>
  
  <pre><code>let backButtonImage = backImage?.withRenderingMode(.alwaysOriginal).resizableImage(withCapInsets: UIEdgeInsetsMake((backImage?.size.height)!, (backImage?.size.width)!, 0, 0))
  UIBarButtonItem.appearance().setBackButtonBackgroundImage(backButtonImage, for: .normal, barMetrics: .default)
  UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(-400, 0), for: .default)
  </code></pre>
  
  <p>from <a href="https://stackoverflow.com/questions/41690454/update-navigation-bar-back-button-image-for-the-whole-project">here</a> .</p>
  
  <p>But the UI is not correct: </p>
  
  <p><a href="https://i.stack.imgur.com/YIAPX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YIAPX.png" alt="enter image description here"></a></p>
  
  <p>I have also tried below code :</p>
  
  <pre><code>UINavigationBar.appearance().backIndicatorImage = backButtonImage
  UINavigationBar.appearance().backIndicatorTransitionMaskImage = backButtonImage
  UIBarButtonItem.appearance().setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -80.0), for: .default)
  </code></pre>
  
  <p>which looks like this:</p>
  
  <p><a href="https://i.stack.imgur.com/LLea5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LLea5.png" alt="enter image description here"></a></p>
  
  <p>But it is giving constraint issues in the terminal: </p>
  
  <pre><code>[LayoutConstraints] Unable to simultaneously satisfy constraints.
      Probably at least one of the constraints in the following list is one you don't want. 
      Try this: 
          (1) look at each constraint and try to figure out which you don't expect; 
          (2) find the code that added the unwanted constraint or constraints and fix it. 
  (
      "&lt;NSLayoutConstraint:0x600000098510 UILayoutGuide:0x6040007aca20'BackButtonGuide(0x7f8143611390)'.height == 44   (active)&gt;",
      "&lt;NSLayoutConstraint:0x60000029e320 _UIButtonBarButton:0x7f814349d110.top == UILayoutGuide:0x6040007aca20'BackButtonGuide(0x7f8143611390)'.top   (active)&gt;",
      "&lt;NSLayoutConstraint:0x60000029de20 _UIButtonBarButton:0x7f814349d110.bottom == UILayoutGuide:0x6040007aca20'BackButtonGuide(0x7f8143611390)'.bottom   (active)&gt;",
      "&lt;NSLayoutConstraint:0x60400049d790 _UIModernBarButton:0x7f81434a4800'Back'.lastBaseline == UILayoutGuide:0x6000001b51c0'UIViewLayoutMarginsGuide'.bottom - 80   (active)&gt;",
      "&lt;NSLayoutConstraint:0x60400049d1a0 _UIModernBarButton:0x7f81434a4800'Back'.top &gt;= _UIButtonBarButton:0x7f814349d110.top   (active)&gt;",
      "&lt;NSLayoutConstraint:0x600000481040 UIButtonLabel:0x7f81434a30d0'Back'.centerY == _UIModernBarButton:0x7f81434a4800'Back'.centerY + 1.5   (active)&gt;",
      "&lt;NSLayoutConstraint:0x60000029ea00 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x6000001b51c0'UIViewLayoutMarginsGuide']-(16)-|   (active, names: '|':_UIButtonBarButton:0x7f814349d110 )&gt;"
  )
  
  Will attempt to recover by breaking constraint 
  &lt;NSLayoutConstraint:0x600000481040 UIButtonLabel:0x7f81434a30d0'Back'.centerY == _UIModernBarButton:0x7f81434a4800'Back'.centerY + 1.5   (active)&gt;
  
  Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
  The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in &lt;UIKit/UIView.h&gt; may also be helpful.
  
  
  [LayoutConstraints] Unable to simultaneously satisfy constraints.
  Probably at least one of the constraints in the following list is one you don't want.
      Try this:
      (1) look at each constraint and try to figure out which you don't expect; 
  
  (2) find the code that added the unwanted constraint or constraints and fix it. 
  (
      "&lt;NSLayoutConstraint:0x60000029f1d0 _UIModernBarButton:0x7f814360f630.bottom == UILayoutGuide:0x6040007ac940'UIViewLayoutMarginsGuide'.bottom + 84.5   (active)&gt;",
      "&lt;NSLayoutConstraint:0x600000287bc0 V:[_UIModernBarButton:0x7f814360f630]-(&gt;=0)-|   (active, names: '|':_UIButtonBarButton:0x7f814360d8a0 )&gt;",
      "&lt;NSLayoutConstraint:0x604000488930 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x6040007ac940'UIViewLayoutMarginsGuide']-(16)-|   (active, names: '|':_UIButtonBarButton:0x7f814360d8a0 )&gt;"
  )
  
  Will attempt to recover by breaking constraint 
  &lt;NSLayoutConstraint:0x60000029f1d0 _UIModernBarButton:0x7f814360f630.bottom == UILayoutGuide:0x6040007ac940'UIViewLayoutMarginsGuide'.bottom + 84.5   (active)&gt;
  
  Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
  The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in &lt;UIKit/UIView.h&gt; may also be helpful.
  </code></pre>
  
  <p>Is there any other way of doing it or I am doing something wrong ?</p>