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

      运行程序

  • 相关阅读:
    oracle 分配表权限给用户的写法
    任务的一种写法:
    解决oracle 32位64位的问题
    设计模式学习
    Nginx 相关介绍
    (2) html 语义化
    (1)HTML5的常用新特性你必须知道
    less初学手记
    如何修改chrome记住密码后自动填充表单的黄色背景 ?
    HTML的水平居中和垂直居中解决方案
  • 原文地址:https://www.cnblogs.com/bubugao/p/4488692.html
Copyright © 2011-2022 走看看