[英]set background image navigation bar
因此,我嘗試在MonoTouch中為導航欄設置背景圖像。 圖像到處都是一樣的。 我該怎么辦?
在viewdid加載中: NavBar.SetBackgroundImage(UIImage.FromFile ("btn-title-bar.png"));
不起作用。
嘗試
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"btn-title-bar.png"] forBarMetrics:UIBarMetricsDefault];
在c#領域中是:
UINavigationBar.Appearance.SetBackgroundImage (UIImage.FromFile ("btn-title-bar.png"), UIBarMetrics.Default);
試試下面的代碼。
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];
如果要在每個頁面上放置不同的圖像,則在視圖加載到每個頁面的情況下編寫此方法。
UIImage *image = [UIImage imageNamed: @"logo.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
self.navigationItem.titleView = imageView;
如果您想在每個頁面上顯示單個圖像,則將這段代碼編寫在delegate.m中。
[[UINavigationBar appearance] setBackgroundImage:[UIImage imageNamed:@"logo.png"]
forBarMetrics:UIBarMetricsDefault];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.