XCode: background image per UINavigationBar
La visualizzazione di un’immagine di sfondo per la NavigationBar va fatta in modo differente in base alla versione di IOS utilizzata. Il codice seguente permette di impostare un’immagina di bckground nel corretto modo, sia se si usa IOS5 che IOS4:
1 2 3 4 5 6 7 8 | UINavigationBar*theBar=self.navigationController.navigationBar; if([theBar respondsToSelector:@selector(setBackgroundImage:forBarMetrics:)]){ //IOS 5 [theBar setBackgroundImage:[UIImage imageNamed:logoName] forBarMetrics:UIBarMetricsDefault]; }else{ //IOS 4 [theBar insertSubview:[[UIImageViewalloc] initWithImage:[UIImage imageNamed:logoName]] atIndex:0]; } |