[英]set background image navigation bar
So I am try to set a background image for a navigation bar in MonoTouch. 因此,我尝试在MonoTouch中为导航栏设置背景图像。 The image will be the same everywhere. 图像到处都是一样的。 How would i do this? 我该怎么办?
In the viewdid load: NavBar.SetBackgroundImage(UIImage.FromFile ("btn-title-bar.png"));
在viewdid加载中: NavBar.SetBackgroundImage(UIImage.FromFile ("btn-title-bar.png"));
doesn't work. 不起作用。
尝试
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"btn-title-bar.png"] forBarMetrics:UIBarMetricsDefault];
在c#领域中是:
UINavigationBar.Appearance.SetBackgroundImage (UIImage.FromFile ("btn-title-bar.png"), UIBarMetrics.Default);
Try this below code. 试试下面的代码。
UIImage *image = [UIImage imageNamed: @"NavigationBar@2x.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
imageView.frame = CGRectMake(0, 0, 320, 44);
[self.navigationController.navigationBar addSubview:imageView];
if you want to put different images on every page then write this method in view did load on every page.. 如果要在每个页面上放置不同的图像,则在视图加载到每个页面的情况下编写此方法。
UIImage *image = [UIImage imageNamed: @"logo.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
self.navigationItem.titleView = imageView;
and if u want single image on every page then write this code in delegate.m. 如果您想在每个页面上显示单个图像,则将这段代码编写在delegate.m中。
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"logo.png"]
forBarMetrics:UIBarMetricsDefault];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.