当前位置: 首页>>代码示例>>C#>>正文


C# UIView.AddSubview方法代码示例

本文整理汇总了C#中UIView.AddSubview方法的典型用法代码示例。如果您正苦于以下问题:C# UIView.AddSubview方法的具体用法?C# UIView.AddSubview怎么用?C# UIView.AddSubview使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UIView的用法示例。


在下文中一共展示了UIView.AddSubview方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DisabledView

		public DisabledView(OverlayDetails details) : base (details)
		{
			var bounds = UIScreen.MainScreen.ApplicationFrame;

			SetFrame ();

			container = new UIView ();
			container.Frame = new CoreGraphics.CGRect (0, 0, bounds.Width, 65);

			var label1 = new UILabel ();
			label1.Frame = new CoreGraphics.CGRect (0, 10, bounds.Width, 20);
			label1.TextAlignment = UITextAlignment.Center;
			label1.Text = "Something bad happened.";
			container.AddSubview (label1);

			var label2 = new UILabel ();
			label2.Frame = new CoreGraphics.CGRect (0, 35, bounds.Width, 20);
			label2.TextAlignment = UITextAlignment.Center;
			label2.Text = "Try your request again.";
			container.AddSubview (label2);


			// derive the center x and y
			nfloat centerX = Frame.Width / 2;
			nfloat centerY = Frame.Height / 2;

			container.Frame = new CGRect ( 
				centerX - (container.Frame.Width / 2) ,
				centerY - (container.Frame.Height /2),
				container.Frame.Width ,
				container.Frame.Height);

			AddSubview (container);
		}
开发者ID:ddomengeaux,项目名称:xamarin-amccorma,代码行数:34,代码来源:DisabledView.cs

示例2: UIViewDatePicker

		/// <summary>
		/// 
		/// </summary>
		public UIViewDatePicker (UIView owner)
		{
			// save our uiview owner
			this.owner = owner;
	
			// configure the title label
			titleLabel.BackgroundColor = UIColor.Clear;
			titleLabel.TextColor = UIColor.LightTextColor;
			titleLabel.Font = UIFont.BoldSystemFontOfSize (18);
			
			// configure the done button
			doneButton.SetTitle ("done", UIControlState.Normal);
			//doneButton.TouchUpInside += (s, e) => { actionSheet.DismissWithClickedButtonIndex (0, true); };

			doneButton.TouchUpInside += async (sender, e) => { 
				Hide(true);
			};
			
			// create + configure the action sheet
			datePickerView = new UIView () {  };
			//actionSheet.Clicked += (s, e) => { Console.WriteLine ("Clicked on item {0}", e.ButtonIndex); };
	
			// add our controls to the action sheet
			datePickerView.AddSubview (datePicker);
			datePickerView.AddSubview (titleLabel);
			datePickerView.AddSubview (doneButton);
		}
开发者ID:hahmed,项目名称:mobile-samples,代码行数:30,代码来源:UIViewDatePicker.cs

示例3: FinishedLaunching

        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            App_Window = new UIWindow(UIScreen.MainScreen.Bounds);
            var vc = new UIViewController();
            var view = new UIView();

            var button = UIButton.FromType(UIButtonType.RoundedRect);
            button.Frame = new RectangleF(0, 0, 100, 40);
            button.SetTitle("Do It", UIControlState.Normal);
            button.TouchDown += delegate {
                Test_JSON();
            };
            view.AddSubview(button);

            Browser = new UIWebView();
            Browser.Frame = new RectangleF(0, 50, UIScreen.MainScreen.Bounds.Width,
                UIScreen.MainScreen.Bounds.Height-50);
            view.AddSubview(Browser);

            vc.View = view;
            App_Window.RootViewController = vc;
            App_Window.MakeKeyAndVisible();

            return true;
        }
开发者ID:t9mike,项目名称:ServiceStack-JSON1,代码行数:25,代码来源:AppDelegate.cs

示例4: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            UIView view = new UIView(new RectangleF(0,0,320,396)) {
                BackgroundColor = UIColor.GroupTableViewBackgroundColor
            };

            textName.Placeholder = "your note name";
            textName.BorderStyle = UITextBorderStyle.RoundedRect;
            view.AddSubview(textName);

            textBody.Placeholder = "your note body";
            textBody.BorderStyle = UITextBorderStyle.RoundedRect;
            view.AddSubview(textBody);

            this.View.AddSubview(view);

            if (_isUpdateMode()) {
                this.NavigationItem.SetRightBarButtonItem(
                    new UIBarButtonItem("Update", UIBarButtonItemStyle.Bordered, _updateNote), false);

                SetToolbarItems(new UIBarButtonItem[]{
                    new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace, null),
                    new UIBarButtonItem(UIBarButtonSystemItem.Trash, _deleteNote)
                }, false);
            }
            else
                this.NavigationItem.SetRightBarButtonItem(
                    new UIBarButtonItem(UIBarButtonSystemItem.Save, _saveNote), false);
        }
开发者ID:fdibartolo,项目名称:MobileAcademyDemo,代码行数:31,代码来源:NoteDetailsViewController.cs

示例5: BuildHeaderView

        public static UIView BuildHeaderView(string caption)
        {
            UIView view = new UIView(new RectangleF(0,0,320,23));

            UIImageView background = new UIImageView(Resources.SectionHeaderBackground);
            background.Frame = view.Frame;

            UILabel label = new UILabel();
            label.BackgroundColor = UIColor.Clear;
            label.Opaque = false;
            label.TextColor = UIColor.FromRGB(119,119,119);
            //label.HighlightedTextColor = UIColor.White;
            label.Font = UIFont.BoldSystemFontOfSize(13.5f); //UIFont.FromName("Helvetica Neue Bold", 13.5f);
            label.Frame = new RectangleF(8,0,200,23);
            label.Text = caption;
            //var layer = label.Layer;
            label.ShadowColor = UIColor.FromRGBA(255,255,255,128);
            //layer.ShadowRadius = 5f;
            label.ShadowOffset = new SizeF(0, 1);
            //layer.ShadowOpacity = 1.0f;

            view.AddSubview(background);
            view.AddSubview(label);

            return view;
        }
开发者ID:rmawani,项目名称:themesystem,代码行数:26,代码来源:BTBackgroundImageSection.cs

示例6: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            _container = new UIView ();
            View.AddSubview (_container);
            _container.Frame = _container.Superview.Bounds;
            _container.BackgroundColor = UIColor.Gray;

            _imageView = new UIImageView ();
            _container.AddSubview (_imageView);

            _navigationBar = new UINavigationBar ();
            _navigationBar.Frame = new RectangleF (0f, 0f, 320f, 55f);
            _navigationBar.BarStyle = UIBarStyle.Default;

            UINavigationItem navItems = new UINavigationItem { LeftBarButtonItem = new UIBarButtonItem("Меню", UIBarButtonItemStyle.Plain, OnMenuButtonPressed) };
            _navigationBar.Items = new UINavigationItem[]
            {
                navItems
            };
            _container.AddSubview(_navigationBar);

            _sideBarMediator = new SideBarMediator(this, _container, _sideBar, 260f);

            SetImage(UIImage.FromFile("wishlist.png"));
        }
开发者ID:rzaitov,项目名称:IOSSideBar,代码行数:27,代码来源:ContentViewController.cs

示例7: SampleMain

        //最開始執行的程式
        public SampleMain(UIView pContainer)
        {
            mContainer = pContainer;

            mLabel = new UILabel ();
            mLabel.Frame = new RectangleF (10, 10, 300, 100);
            mIncButton = new UIButton (UIButtonType.RoundedRect);
            mIncButton.Frame = new RectangleF (10, 110, 100, 80);
            mDecButton = new UIButton (UIButtonType.RoundedRect);
            mDecButton.Frame = new RectangleF (120, 110, 100, 80);

            mContainer.AddSubview (mLabel);
            mContainer.AddSubview (mIncButton);
            mContainer.AddSubview (mDecButton);

            // Simple MVC Start!
            mModel = new Model ();//要實體化model後才能夠在裡面存東西
            mTextView = new TextViews (mLabel);//把會因為model改變的Label丟進LabelView裡面
            mTextView.Model = mModel;//當然還要告訴view說model是誰

            mController = new Controllers (mModel);//control當然也要知道model是誰,所以把model丟進去
            mController.AddIncButton (mIncButton);//把會在mvc中用到的控制項作設定
            mController.AddDecButton (mDecButton);
            Console.WriteLine ("MVC Start!");
            // Simple MVC End!
        }
开发者ID:WildenChen,项目名称:MonoTouch-Sample-MVC,代码行数:27,代码来源:SampleMain.cs

示例8: LoadView

        //Recipe 2-1 Adding Nested Subviews
        public override void LoadView()
        {
            //Create the main view
            RectangleF appRect = UIScreen.MainScreen.ApplicationFrame;

            contentView = new UIView(appRect);
            contentView.BackgroundColor = UIColor.Green;

            //Provide support for autorotation and resizing
            contentView.AutosizesSubviews = true;
            contentView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            this.View = contentView;

            // reset the origin point for subviews. The new origin is 0, 0
            appRect.Location = new PointF(0.0f, 0.0f);

            //Add the subviews, each stepped by 32 pixels on each side
            var subview = new UIView(RectangleF.Inflate(appRect, -32.0f, -32.0f));
            subview.BackgroundColor = UIColor.Clear;
            contentView.AddSubview(subview);

            subview = new UIView(RectangleF.Inflate(appRect, -64.0f, -64.0f));
            subview.BackgroundColor = UIColor.DarkGray;
            contentView.AddSubview(subview);

            subview = new UIView(RectangleF.Inflate(appRect, -96.0f, -96.0f));
            subview.BackgroundColor = UIColor.Black;
            contentView.AddSubview(subview);
        }
开发者ID:lobrien,项目名称:iPhone-Developer-s-Cookbook-in-Monotouch,代码行数:30,代码来源:MyViewController.cs

示例9: LoadView

        public override void LoadView()
        {
            View = new UIView();
            View.BackgroundColor = UIColor.LightGray;

            RectangleF f = new RectangleF(10,10,300, 44);
            UsernameTextField = new UITextField(f) {
                Placeholder = "Username",
                BorderStyle = UITextBorderStyle.RoundedRect,
                AutocapitalizationType = UITextAutocapitalizationType.None,
                AutocorrectionType = UITextAutocorrectionType.No
            };
            View.AddSubview(UsernameTextField);

            f.Offset(new PointF(0, f.Height + 10));
            PasswordTextField = new UITextField(f) {
                Placeholder = "Password",
                BorderStyle = UITextBorderStyle.RoundedRect,
                SecureTextEntry = true
            };
            View.AddSubview(PasswordTextField);

            f.Offset(new PointF(0, f.Height + 10));
            UIButton button = UIButton.FromType(UIButtonType.RoundedRect);
            button.SetTitle("Login", UIControlState.Normal);
            button.Frame = f;
            button.TouchUpInside += LoginHandler;
            View.AddSubview(button);
        }
开发者ID:juliengrimault,项目名称:FunWithXamarin,代码行数:29,代码来源:LoginViewController.cs

示例10: SaveAndLaunchFile

        public Task SaveAndLaunchFile(Stream stream, string fileType)
        {
            if (OriginView == null) return Task.FromResult(true);

            var data = NSData.FromStream(stream);
            var width = 824;
            var height = 668;

            var popoverView = new UIView(new RectangleF(0, 0, width, height));
            popoverView.BackgroundColor = UIColor.White;
            var webView = new UIWebView();
            webView.Frame = new RectangleF(0, 45, width, height - 45);

            var b = new UIButton(UIButtonType.RoundedRect);
            b.SetTitle("Done", UIControlState.Normal);
            b.Frame = new RectangleF(10,10, 60, 25);
            b.TouchUpInside += (o, e) => _popoverController.Dismiss(true);

            popoverView.AddSubview(b);
            popoverView.AddSubview(webView);

            var bundlePath = NSBundle.MainBundle.BundlePath;
            System.Diagnostics.Debug.WriteLine(bundlePath);
            webView.LoadData(data, "application/pdf", "utf-8", NSUrl.FromString("http://google.com"));

            var popoverContent = new UIViewController();
            popoverContent.View = popoverView;

            _popoverController = new UIPopoverController(popoverContent);
            _popoverController.PopoverContentSize = new SizeF(width, height);
            _popoverController.PresentFromRect(new RectangleF(OriginView.Frame.Width/2, 50, 1, 1), OriginView, UIPopoverArrowDirection.Any, true);
            _popoverController.DidDismiss += (o, e) => _popoverController = null;

            return Task.FromResult(true);
        }
开发者ID:reactiveui-forks,项目名称:VirtualSales,代码行数:35,代码来源:PlatformServices.cs

示例11: CreateAccessory

        private UIView CreateAccessory()
        {
            RectangleF app = UIScreen.MainScreen.ApplicationFrame;
            const float btnWidth = 40;
            const float btnHeight = 40;
            const float margin = 5;

            _accessory = new UIView(new RectangleF(0, 0, 1, btnHeight));
            _accessory.BackgroundColor = UIColor.White;
            _accessory.ClipsToBounds = true;
            _accessory.Layer.BorderWidth = 1/UIScreen.MainScreen.Scale;
            _accessory.Layer.BorderColor = UIColor.LightGray.CGColor;

            _back = new UIButton(UIButtonType.System);
            _back.Frame = new RectangleF(app.Width - btnWidth - margin - btnWidth - margin - btnWidth, 0, btnWidth,
                btnHeight);
            _back.SetTitle("<", UIControlState.Normal);
            _back.TouchUpInside += HandleBack;
            _accessory.AddSubview(_back);

            _next = new UIButton(UIButtonType.System);
            _next.Frame = new RectangleF(app.Width - btnWidth - margin - btnWidth, 0, btnWidth, btnHeight);
            _next.SetTitle(">", UIControlState.Normal);
            _next.TouchUpInside += HandleNext;
            _accessory.AddSubview(_next);

            _cancel = new UIButton(UIButtonType.System);
            _cancel.Frame = new RectangleF(app.Width - btnWidth, 0, btnWidth, btnHeight);
            _cancel.SetTitle("x", UIControlState.Normal);
            _cancel.TouchUpInside += HandleCancel;
            _accessory.AddSubview(_cancel);

            return _accessory;
        }
开发者ID:Fedorm,项目名称:core-master,代码行数:34,代码来源:TabOrderManager.cs

示例12: GetView

        public override UIView GetView( UIPickerView pickerView, nint row, nint component, UIView view )
        {
            nfloat width = pickerView.RowSizeForComponent(component).Width;
            nfloat height = pickerView.RowSizeForComponent(component).Height;

            var pickerCustomView = new UIView {
                Frame = new CGRect(0, 0, width - 10, height)
            };
            var pickerImageView = new UIImageView {
                Frame = new CGRect(20, height/4, height/2, height/2)
            };
            var pickerViewLabel = new UILabel {
                Frame = new CGRect(20 + height, 0, width - 10, height)
            };

            pickerCustomView.AddSubview(pickerImageView);
            pickerCustomView.AddSubview(pickerViewLabel);

            Category category = CategoryHelper.AllCategories[(int) row];

            pickerImageView.Image = new UIImage(category.IconSource);
            pickerViewLabel.BackgroundColor = UIColor.Clear;
            pickerViewLabel.Text = category.Name;
            pickerViewLabel.TextColor = category.Color.ToUIColor();

            return pickerCustomView;
        }
开发者ID:strongloop,项目名称:loopback-example-xamarin,代码行数:27,代码来源:CategoryPickerDelegate.cs

示例13: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            UIView header = new UIView(new System.Drawing.RectangleF(0, 0, 0, 184f));
            UIImageView imageView = new UIImageView(new System.Drawing.RectangleF(0, 40f, 100f, 100f));
            imageView.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
            imageView.Image = UIImage.FromBundle("avatar.jpg");
            imageView.Layer.MasksToBounds = true;
            imageView.Layer.CornerRadius = 50f;
            imageView.Layer.BorderColor = UIColor.White.CGColor;
            imageView.Layer.BorderWidth = 3f;
            imageView.Layer.RasterizationScale = UIScreen.MainScreen.Scale;
            imageView.Layer.ShouldRasterize = true;
            imageView.ClipsToBounds = true;

            UILabel label = new UILabel(new System.Drawing.RectangleF(0, 150f, 0, 24f)){
                Text = "Roman Efimov",
                Font = UIFont.SystemFontOfSize(21f),
                BackgroundColor = UIColor.Clear,
                TextColor = UIColor.FromRGBA(62/255f, 68/255f, 75/255f, 1f)
            };
            label.SizeToFit();
            label.AutoresizingMask = UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
            header.AddSubview(imageView);
            header.AddSubview(label);

            TableView.SeparatorColor = UIColor.FromRGBA(150/255f, 161/255f, 177/255f, 1f);
            TableView.Source = new DEMOTableSource(this);
            TableView.Opaque = false;
            TableView.BackgroundColor = UIColor.Clear;
            TableView.TableHeaderView = header;
        }
开发者ID:TMAgostinho,项目名称:REFrostedViewController,代码行数:33,代码来源:DEMOMenuViewController.cs

示例14: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            _thread = new Thread(ThreadEntry);

            // Container for the controls
            _containerView = new UIView();
            _containerView.Frame = new RectangleF(0,-20,320,480);

            // The background loading image
            _imageView = new UIImageView();
            _imageView.Image = UIImage.FromFile("Default.png");
            _imageView.Frame = new RectangleF(0,0,320,480);
            _containerView.AddSubview(_imageView);

            // The pulser
            _activityView = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.White);
            _activityView.Frame = new RectangleF(115,280,20,20);
            _containerView.AddSubview(_activityView);
            _activityView.StartAnimating();

            // Label saying wait
            _label = new UILabel();
            _label.Frame = new RectangleF(140,280,250,20);
            _label.Font = UIFont.SystemFontOfSize(14f);
            _label.BackgroundColor = UIColor.Clear;
            _label.TextColor = UIColor.White;
            _label.ShadowColor = UIColor.Black;
            _label.Text = "Loading...";
            _containerView.AddSubview(_label);

            View.AddSubview(_containerView);
        }
开发者ID:yetanotherchris,项目名称:really-simple,代码行数:34,代码来源:SplashScreenController.cs

示例15: ShowPanel

        public static void ShowPanel(string title, UIView view, Action<Dictionary<string, object>> editingEndedBlock)
        {
            MKEntryPanel panel = GetPanel ();
            panel.closeBlock = editingEndedBlock;
            panel.titleLabel.Text = title;
            panel.titleLabel.BackgroundColor = UIColor.Clear;
            panel.entryField.Font = UIFont.FromName ("DINPro-Medium", 16);
            panel.entryField.LeftView = new UIView (new RectangleF(0, 0, 5, 31));
            panel.entryField.LeftViewMode = UITextFieldViewMode.Always;
            panel.entryField.Background = CashflowTheme.SharedTheme.TextBackground.CreateResizableImage (new UIEdgeInsets(5, 10, 5, 10));
            panel.valueField.Font = UIFont.FromName ("DINPro-Medium", 16);
            panel.valueField.RightView = new UIView (new RectangleF(0, 0, 5, 31));
            panel.valueField.RightViewMode = UITextFieldViewMode.Always;
            panel.valueField.Background = CashflowTheme.SharedTheme.TextBackground.CreateResizableImage (new UIEdgeInsets(5, 10, 5, 10));
            panel.valueField.TextAlignment = UITextAlignment.Right;
            panel.entryField.BecomeFirstResponder ();

            panel.dimView = new UIControl (UIScreen.MainScreen.Bounds);
            CATransition transition = CATransition.CreateAnimation ();
            transition.Duration = kAnimationDuration;
            transition.TimingFunction = CAMediaTimingFunction.FromName (CAMediaTimingFunction.EaseInEaseOut);
            transition.Type = CATransition.TransitionFade.ToString ();
            panel.dimView.Layer.AddAnimation (transition, null);
            panel.dimView.BackgroundColor = UIColor.Black;
            panel.dimView.Alpha = 0.8f;
            panel.dimView.TouchDown += (sender, e) => panel.CancelTapped ();
            view.AddSubview (panel.dimView);
            view.AddSubview (panel);
        }
开发者ID:alleeclark,项目名称:morganHack,代码行数:29,代码来源:MKEntryPanel.cs


注:本文中的UIView.AddSubview方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。