2012-12-07 49 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/

希望这会帮助你。