2014-08-30 126 views
1

我有下面的代碼爲導航欄的背景顯示圖片:如何停止導航欄背景圖片停止重複?

UIImage *imgNav = [UIImage imageNamed:@"backgroundimage.png"]; 
self.navigationController.navigationBar.frame = CGRectMake(0, 0, 320, 44); 
[self.navigationController.navigationBar setBackgroundImage:imgNav forBarMetrics: 
UIBarMetricsDefault]; 

的影像尺寸爲60 42。現在我只想一個圖像的單個實例,但它重複。如何禁用它?我想要在導航欄中心的圖像的單個實例。

回答

0

enter image description here

我覺得身體不明白我的問題是我不好。 !我應該早些時候發佈這個圖片。

但我自己解決了。這不會發生,如果你使圖像完全320×44像素,因爲這是導航欄的大小。

或者如果你只是想在屏幕中心設置標題圖片應該以這種方式實現在一個視圖控制器:

self.navigationItem.titleView = 
[[UIImageView alloc] initWithImage: 
[UIImage imageNamed:@"header_logo.png"]];