2014-09-01 3 views
0

En utilisant le code suivant pour définir une navigation globale bouton retour d'image:iOS 7 image setBackButtonBackgroundImage est toujours étirée

float imageSize = 21.5; // @2x is 43px width 

UIImage *barBackBtnImg = [[UIImage imageNamed:@"arrow-back-white"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, imageSize, 0, 0)]; 

[[UIBarButtonItem appearance] setBackButtonBackgroundImage:barBackBtnImg 
                forState:UIControlStateNormal 
               barMetrics:UIBarMetricsDefault]; 
[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) 
                forBarMetrics:UIBarMetricsDefault]; 

image originale: http://cl.ly/XJgD et en application (être étirées): http://cl.ly/XKc0

Toutes les idées pourquoi l'image est encore étirée?

Répondre

10

Si quelqu'un est intéressé, ce fut ma solution:

[[UINavigationBar appearance] setBackIndicatorImage:[UIImage imageNamed:@"arrow-back-white"]]; 
[[UINavigationBar appearance] setBackIndicatorTransitionMaskImage:[UIImage imageNamed:@"arrow-back-white"]]; 
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]]; 
+0

Très bonne solution, merci! – Alex

+1

J'ai dû utiliser l'affectation directe de paramètres, comme ceci: UINavigationBar.appearance(). BackIndicatorImage = UIImage (nommé: "btn-back"); UINavigationBar.appearance(). BackIndicatorTransitionMaskImage = UIImage (nommé: "btn-back"); UINavigationBar.appearance(). TintColor = UIColor.blackColor(); – Jonauz

+0

Bonne solution. Merci – Kit