public TasksViewController()
        {
            MyNavigationController.View.TranslatesAutoresizingMaskIntoConstraints = false;
            MyNavigationController.View.StretchWidth(base.View);

            var statusBar = UIStatusBarView.CreateAndAddTo(View);

            NavBar = new UINavigationBar()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            ColorResources.ConfigureNavBar(NavBar);
            base.View.Add(NavBar);
            NavBar.StretchWidth(base.View);

            NavItem      = new UINavigationItem();
            NavBar.Items = new UINavigationItem[] { NavItem };

            _viewSelectedItemAndArrow = new UIControl();
            _labelSelectedItem        = new UILabel()
            {
                TextColor = UIColor.White
            };
            _viewSelectedItemAndArrow.Add(_labelSelectedItem);
            _imageSelectedItemDownArrow = new UIImageView(UIImage.FromBundle("ToolbarDown").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate))
            {
                TintColor   = UIColor.White,
                ContentMode = UIViewContentMode.ScaleAspectFit
            };
            _viewSelectedItemAndArrow.Add(_imageSelectedItemDownArrow);
            _viewSelectedItemAndArrow.TouchUpInside += new WeakEventHandler(ButtonSwitchView_Clicked).Handler;

            NavItem.Title             = "";
            NavItem.LeftBarButtonItem = new UIBarButtonItem(_viewSelectedItemAndArrow);

            NavItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Add)
            {
                Title = "Add item"
            };
            NavItem.RightBarButtonItem.Clicked += new WeakEventHandler <EventArgs>(ButtonAddItem_Clicked).Handler;

            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[statusBar][navBar][mainView]|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                    "statusBar", statusBar,
                                                                    "navBar", NavBar,
                                                                    "mainView", MyNavigationController.View));
        }
示例#2
0
        public PopupViewController()
        {
            AutomaticallyAdjustsScrollViewInsets = false;

            _contentView = new UIView()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            base.View.Add(_contentView);
            _contentView.StretchWidth(base.View);

            var statusBarView = UIStatusBarView.CreateAndAddTo(View);

            NavBar = new UINavigationBar()
            {
                TranslatesAutoresizingMaskIntoConstraints = false
            };
            ColorResources.ConfigureNavBar(NavBar);
            base.View.Add(NavBar);
            NavBar.StretchWidth(base.View);

            _backButton = new UIBarButtonItem()
            {
                Title = "Back"
            };
            _backButton.Clicked += new WeakEventHandler <EventArgs>(_backButton_Clicked).Handler;

            NavItem = new UINavigationItem();
            NavItem.LeftBarButtonItem = _backButton;
            NavBar.Items = new UINavigationItem[] { NavItem };

            View.AddConstraints(NSLayoutConstraint.FromVisualFormat("V:|[statusBar][navBar][contentView]|", NSLayoutFormatOptions.DirectionLeadingToTrailing,
                                                                    "statusBar", statusBarView,
                                                                    "navBar", NavBar,
                                                                    "contentView", _contentView));
        }