开发者

Use Background Image to UINavigationController among multiple views

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 ima开发者_如何学Cge and keep the text. But if the user navigates to other view ( using [navigationController pushViewController]), only the background appears in the new screen.

How can one change the background image for UINavigationController, while maintaining the title across multiple views?


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"]];
}

After that, use your CustomUIViewController in your controllers.


And if you want to use ImageView to scale it :

UIImageView *imageView = [[UIImageView alloc] initWithFrame:controller.view.bounds];
imageView.image = [UIImage imageNamed:@"aluminium-brushed-metal-background-texture-hd-575x400.jpg"];
imageView.contentMode = UIViewContentModeScaleAspectFill;
[navigationController.view insertSubview:imageView atIndex:0];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜