開發(fā)中基本上每個(gè)界面都會(huì)有導(dǎo)航欄,來控制你每個(gè)界面從哪來到哪去。
通常的情況都是導(dǎo)航欄左側(cè)一個(gè)返回按鈕,中間文字展示這個(gè)界面是干嘛的。
偶爾也會(huì)出現(xiàn)右側(cè)一個(gè)圖標(biāo)或者文字,來增加一些功能。本篇介紹一下幾個(gè)簡(jiǎn)單位置按鈕設(shè)置。
1.設(shè)置中間文字。
一般都放在ViewController的構(gòu)造里面,下同。
UILabel titleUILabel = new UILabel(new CGRect(0, 0, 100, 35));			titleUILabel.Text = "中間文字";			NavigationItem.TitleView = titleUILabel;			titleUILabel.TextAlignment = UITextAlignment.Center;			titleUILabel.TextColor = UIColor.White;2.設(shè)置右側(cè)按鈕(圖片)。// 右側(cè)成長(zhǎng)記錄按鈕			var rightImg = UIImage.FromBundle("圖片資源路徑");			UIBarButtonItem rightBtn = new UIBarButtonItem(rightImg, UIBarButtonItemStyle.Plain				, (sender, e) =>				{					// 點(diǎn)擊事件				});			NavigationItem.SetRightBarButtonItem(rightBtn, true);
3.左側(cè)返回按鈕(文字代替),右側(cè)按鈕(文字)
// 標(biāo)題右側(cè)保存按鈕			UIBarButtonItem rightItem = new UIBarButtonItem("保存", UIBarButtonItemStyle.Plain, (sender, e) =>			{				// 右側(cè)文字點(diǎn)擊			});			NavigationItem.SetRightBarButtonItem(rightItem, true);			// 取消按鈕			UIBarButtonItem leftItem = new UIBarButtonItem("取消", UIBarButtonItemStyle.Plain				, (sender, e) =>				{					// 左側(cè)文字點(diǎn)擊				});			NavigationItem.SetLeftBarButtonItem(leftItem, true);
| 
 
 | 
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注