所以我嘗試在MonoTouch中爲導航欄設置背景圖像。圖像在任何地方都是一樣的。我將如何做到這一點?設置背景圖像導航欄
在viewdid負載:NavBar.SetBackgroundImage(UIImage.FromFile ("btn-title-bar.png"));
不起作用。
所以我嘗試在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);
錯誤CS1501:方法'SetBackgroundImage'沒有重載需要'1'參數(CS1501) – 2013-03-08 12:41:23
道歉沒有檢查添加。 – Blounty 2013-03-08 19:15:21
鑑於所做的每一頁上加載..
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];
試試下面的代碼。
UIImage *image = [UIImage imageNamed: @"[email protected]"];
UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
imageView.frame = CGRectMake(0, 0, 320, 44);
[self.navigationController.navigationBar addSubview:imageView];
+1不錯的答案。 – Dilip 2013-03-08 12:47:50
是的,這工作!在c#中它將是:gettingStartedBar.SetBackgroundImage(UIImage.FromBundle(「top-bar.png」),UIBarMetrics.Default); – 2013-03-08 12:52:44