zoukankan      html  css  js  c++  java
  • Creating Tabbed Applications

    新建一个空工程,如图

    新建类

    using System;
    using UIKit;
    
    namespace TabbedApplication
    {
    	public class TabController : UITabBarController
    	{
    		UIViewController tab1,tab2,tab3;
    
    		public TabController ()
    		{
    			tab1 = new UIViewController();
    			tab1.Title = "Green";
    			tab1.View.BackgroundColor = UIColor.Green;
    			tab1.TabBarItem = new UITabBarItem (UITabBarSystemItem.Favorites, 0);
    
    			tab2 = new UIViewController();
    			tab2.Title = "Orange";
    			tab2.View.BackgroundColor = UIColor.Orange;
    			tab2.TabBarItem.Image = UIImage.FromFile ("second.png");
    			tab2.Title = "Second";
    
    			tab3 = new UIViewController();
    			tab3.Title = "Red";
    			tab3.View.BackgroundColor = UIColor.Red;
    			tab3.TabBarItem.BadgeValue = "Hi";
    			var tabs = new UIViewController[] {
    				tab1, tab2, tab3
    			};
    
    			ViewControllers = tabs;
    		}
    	}
    }
    

      修改 AppDelegate.cs

    using System;
    using System.Collections.Generic;
    using System.Linq;
    
    using Foundation;
    using UIKit;
    
    namespace TabbedApplication
    {
    	// The UIApplicationDelegate for the application. This class is responsible for launching the
    	// User Interface of the application, as well as listening (and optionally responding) to
    	// application events from iOS.
    	[Register ("AppDelegate")]
    	public partial class AppDelegate : UIApplicationDelegate
    	{
    		// class-level declarations
    		UIWindow window;
    		TabController tabController;
    		//
    		// This method is invoked when the application has loaded and is ready to run. In this
    		// method you should instantiate the window, load the UI into it and then make the window
    		// visible.
    		//
    		// You have 17 seconds to return from this method, or iOS will terminate your application.
    		//
    		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
    		{
    			// create a new window instance based on the screen size
    			window = new UIWindow (UIScreen.MainScreen.Bounds);
    			
    			// If you have defined a root view controller, set it here:
    			// window.RootViewController = myViewController;
    			tabController=new TabController();
    			window.RootViewController = tabController;
    			// make the window visible
    			window.MakeKeyAndVisible ();
    			
    			return true;
    		}
    	}
    }
    

      运行程序

  • 相关阅读:
    c#数据结构与算法
    学习资源---.NET
    怎样完全删除sqlserver
    树,森林 二叉树之间转化 原理
    ref 和out 区别
    GridView批量删除记录、全选及弹出确认对话框
    .NET基础 小记--------2013.8.10
    Xml 读写
    同步 异步 区别
    委托学习
  • 原文地址:https://www.cnblogs.com/bubugao/p/4488692.html
Copyright © 2011-2022 走看看