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

      运行程序

  • 相关阅读:
    说说我当初是如何学Linux的
    案例八:shell自动化管理账本脚本
    案例七:shell实现开机自动播放挂载本地yum仓库程序
    案例六:shell脚本监控httpd服务80端口状态
    案例五:shell脚本实现定时监控http服务的运行状态
    案例四:Shell脚本生成随机密码
    案例三:shell统计ip访问情况并分析访问日志
    案例二:shell脚本获取当前日期和时间及磁盘使情况
    案例一:shell脚本指定日期减去一天
    Linux:保证数据安全落盘
  • 原文地址:https://www.cnblogs.com/bubugao/p/4488692.html
Copyright © 2011-2022 走看看