关闭

Create a TabBar

标签: TabBarControllerTabBarItem
867人阅读 评论(0) 收藏 举报
分类:
[Register ("AppDelegate")]
	public partial class AppDelegate : UIApplicationDelegate
	{
		// class-level declarations
		UIWindow window;
		TabBarController tabBarController;

		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);
			
			tabBarController = new TabBarController();

			// If you have defined a view, add it here:
			window.RootViewController = tabBarController;
			
			// make the window visible
			window.MakeKeyAndVisible ();
			
			return true;
		}
	}
public class TabBarController : UITabBarController 
	{

		UIViewController tab1, tab2, tab3;

		public TabBarController ()
		{
			tab1 = new UIViewController();
			tab1.Title = "Green";
			tab1.View.BackgroundColor = UIColor.Green;
			//===========================
			UIButton btn = new UIButton (UIButtonType.RoundedRect);
			btn.Bounds = new RectangleF (100, 80, 200, 150);
			btn.SetTitle ("tewat", UIControlState.Normal);
			tab1.View.Add (btn);
			btn.TouchUpInside += delegate {
				//...
			};
			//===========================


			tab2 = new UIViewController();
			tab2.Title = "Orange";
			tab2.View.BackgroundColor = UIColor.Orange;

			tab3 = new UIViewController();
			tab3.Title = "Red";
			tab3.View.BackgroundColor = UIColor.Red;
			
			#region Additional Info
//			tab1.TabBarItem = new UITabBarItem (UITabBarSystemItem.History, 0); // sets image AND text
//			tab2.TabBarItem = new UITabBarItem ("Orange", UIImage.FromFile("Images/first.png"), 1);
//			tab3.TabBarItem = new UITabBarItem ();
//			tab3.TabBarItem.Image = UIImage.FromFile("Images/second.png");
//			tab3.TabBarItem.Title = "Rouge"; // this overrides tab3.Title set above
//			tab3.TabBarItem.BadgeValue = "4";
//			tab3.TabBarItem.Enabled = false;
			#endregion

			var tabs = new UIViewController[] {
				tab1, tab2, tab3
			};

			this.ViewControllers =tabs;
			//this.SelectedViewController = tab1; // normally you would default to the left-most tab (ie. tab1)
		}
	}


0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:2275060次
    • 积分:20877
    • 等级:
    • 排名:第422名
    • 原创:324篇
    • 转载:351篇
    • 译文:2篇
    • 评论:187条
    最新评论