问题描述
如何在UINavigationController中使用背景图片,同时保持标题?来自其他线程的的答案图像和保留文本。但如果用户导航到其他视图(使用[navigationController pushViewController]),只有背景出现在新屏幕中。
How can I use a background image for UINavigationController, while maintaining the title? The answer from ck on other thread did the trick to put the image and keep the text. But if the user navigates to other view ( using [navigationController pushViewController]), only the background appears in the new screen.
如何更改UINavigationController的背景图像,同时保持多个视图的标题?
How can one change the background image for UINavigationController, while maintaining the title across multiple views?
推荐答案
创建一个扩展UIViewController并覆盖viewDidLoad的CustomUIViewController:
create a CustomUIViewController that extends UIViewController and override viewDidLoad to something like this:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg.png"]];
}
之后,在您的控制器中使用您的CustomUIViewController。
After that, use your CustomUIViewController in your controllers.
这篇关于在多个视图中使用Background Image到UINavigationController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!