2012-12-07 48 views
2

我用下面的代碼來設置導航欄的背景的其餘部分不一致:的iOS:在的UIImagePickerController背景圖像與應用程序

[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"tile.png"] forBarMetrics:UIBarMetricsDefault]; 

這導致在一個不錯的瓷磚背景如你在這裏看到:

Good background

然而,當我打開一的UIImagePickerController,背景是某種扭曲,我們最終的東西是這樣的:

bad background

任何人都有如何解決它的建議?

+1

這是發生在模擬器和你的物理設備?或者只是其中的一個? –

回答

0

拉伸而不是平鋪:要停止 創建一個類類型UINavigationBar的

  1. 的創建自定義UINavigationBar的子類。

  2. 評論initwithFrameMethod

  3. 添加方法的drawRect:

    • (無效)的drawRect:(的CGRect)RECT { 的UIImage *圖像= [UIImage的imageNamed:@ 「bluebackground.jpeg」]; [image drawInRect:CGRectMake(0,0,self.frame.size.width,self.frame.size.height)]; }

4.in AppDelegate.m,AppliocationdidFinishLaunching 寫 [self.navigationbar的setValue:[[customBar的alloc] INIT] forKeyPath:@ 「的導航欄」];

添加圖像通過這種方式不會延長圖像

請參考以下鏈接: http://www.iosdevnotes.com/2011/09/custom-uinavigationbars-techniques/ http://designm.ag/tutorials/designing-a-custom-iphone-app-navigation-bar/

希望這會幫助你。