• 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;
    		}
    	}
    }
    

      运行程序

  • 相关阅读:
    HAL驱动的串口编程陷阱
    ST推出新软件STM32Cube ,让STM32微控制器应用设计变得更容易、更快、更好用
    零宽断言 -- Lookahead/Lookahead Positive/Negative
    Eclipse 正则表达式 查找与替换
    MSDN WinUSB Example
    培训SQLServer 嵌套事务PPT分享
    SQL Server数据库备份的镜像
    禁用nested loop join里的spool
    日常办公工具利器 notepad++
    Change the Target Recovery Time of a Database (SQL Server) 间接-checkpoints flushcache flushcache-message
  • 原文地址:https://www.cnblogs.com/bubugao/p/4488692.html
Copyright © 2020-2023  润新知