コード例 #1
0
        // Below should be the override and custom methods which will be explained later in this blog.
        // ...

        public void SetImageTitleBackButton(string imageBundleName, string buttonTitle, int horizontalOffset)
        {
            var topVC = this.TopViewController;

            // Create the image back button
            var backButtonImage = new UIBarButtonItem(
                UIImage.FromBundle(imageBundleName),
                UIBarButtonItemStyle.Plain,
                (sender, args) =>
            {
                topVC.NavigationController.PopViewController(true);
            });

            // Create the Text Back Button
            var backButtonText = new UIBarButtonItem(
                buttonTitle,
                UIBarButtonItemStyle.Plain,
                (sender, args) =>
            {
                topVC.NavigationController.PopViewController(true);
            });

            backButtonText.SetTitlePositionAdjustment(new UIOffset(horizontalOffset, 0), UIBarMetrics.Default);

            // Add buttons to the Top Bar
            UIBarButtonItem[] buttons = new UIBarButtonItem[2];
            buttons[0] = backButtonImage;
            buttons[1] = backButtonText;

            topVC.NavigationItem.LeftBarButtonItems = buttons;
        }
コード例 #2
0
        // Sets a Image + Title Back Button
        // -------------------------------
        void SetImageTitleBackButton(string imageBundleName, string buttonTitle, int horizontalOffset)
        {
            var topVC = this.TopViewController;

            // create the image back button
            var backButtonImage = new UIBarButtonItem(
                UIImage.FromBundle(imageBundleName),     // see https://developer.xamarin.com/guides/ios/application_fundamentals/working_with_images/displaying-an-image/
                UIBarButtonItemStyle.Plain,
                (sender, args) =>
            {
                topVC.NavigationController.PopViewController(true);         // event when tapped = go back
            });

            // create the Text Back Button
            var backButtonText = new UIBarButtonItem(
                buttonTitle,
                UIBarButtonItemStyle.Plain,
                (sender, args) =>
            {
                topVC.NavigationController.PopViewController(true);         // event when tapped = go back
            });

            backButtonText.SetTitlePositionAdjustment(new UIOffset(horizontalOffset, 0), UIBarMetrics.Default); //

            // Add the buttons to the Top Bar
            UIBarButtonItem[] buttons = new UIBarButtonItem[2];
            buttons[0] = backButtonImage;
            buttons[1] = backButtonText;

            // Add the buttons to the Top Bar
            topVC.NavigationItem.LeftBarButtonItems = buttons;             // we add 2 buttons (notice property name '...ItemS')
        }
コード例 #3
0
        // Sets a Text only Back button
        // -------------------------------
        void SetTitleBackButton(string buttonTitle, int horizontalOffset)
        {
            // create the image back button
            var backButtonText = new UIBarButtonItem(
                buttonTitle,
                UIBarButtonItemStyle.Plain,
                (sender, args) =>
            {
                this.TopViewController.NavigationController.PopViewController(true);
            });

            backButtonText.SetTitlePositionAdjustment(new UIOffset(horizontalOffset, 0), UIBarMetrics.Default);

            this.TopViewController.NavigationItem.LeftBarButtonItem = backButtonText;
        }
コード例 #4
0
ファイル: WhiteTheme.cs プロジェクト: praeclarum/Praeclarum
		public static void Apply (UIBarButtonItem.UIBarButtonItemAppearance appearance, string options = null)
		{
			if (IsModern)
				return;

			var font = UIFont.FromName (BarButtonFontName, BarButtonFontSize);

			appearance.SetBackgroundImage (
				ButtonImage.Value,
				UIControlState.Normal,
				UIBarMetrics.Default);

			appearance.SetBackButtonBackgroundImage (
				BackButtonImage.Value,
				UIControlState.Normal,
				UIBarMetrics.Default);

			appearance.SetTitlePositionAdjustment (new UIOffset (0, 1), UIBarMetrics.Default);

			appearance.SetTitleTextAttributes (new UITextAttributes {
				TextColor = BarTextColor,
				TextShadowColor = BarButtonTextShadowColor,
				TextShadowOffset = BarButtonTextShadowOffset,
				Font = font,
			}, UIControlState.Normal);

			appearance.SetTitleTextAttributes (new UITextAttributes {
				TextColor = UIColor.FromWhiteAlpha (0.9f, 1),
				TextShadowColor = BarButtonTextShadowColor,
				TextShadowOffset = BarButtonTextShadowOffset,
				Font = font,
			}, UIControlState.Disabled);

			appearance.SetTitleTextAttributes (new UITextAttributes {
				TextColor = UIColor.White,
				TextShadowColor = BarButtonTextShadowColor,
				TextShadowOffset = BarButtonTextShadowOffset,
				Font = font,
			}, UIControlState.Highlighted);
		}
コード例 #5
0
ファイル: ECLSPopover.cs プロジェクト: avantidesai/EmpireCLS
		/// <summary>
		/// Views the did load.
		/// </summary>
		/// 
		public override void ViewDidLoad ()
		{
			ECLSUIUtil.TryAction<ECLSPopover> ("ViewDidLoad", () => {
				base.ViewDidLoad ();

				// default frame size
				this.View.Frame = OnGetFrame ();

				if (_style == ECLSPopoverStyle.OkCancel) {
					_navigationBar = new UINavigationBar (
						CGRect.FromLTRB (0, 0, UIApplication.SharedApplication.Delegate.GetWindow ().Frame.Width, 44)

					);
					_navigationBar.BackgroundColor = UIColor.DarkGray; //UIColor.FromRGB (175,1,83); //magenta
					//	_navigationBar.TintColor = UIColor.FromRGB (175,1,83); // UIColor.White; 
					
					_leftBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Cancel);                    
					_rightBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Done);
					_leftBarButtonItem.SetTitlePositionAdjustment (new UIOffset (15f, 0), UIBarMetrics.Default);
					_rightBarButtonItem.SetTitlePositionAdjustment (new UIOffset (-15f, 0), UIBarMetrics.Default);
					UINavigationItem navItem = new UINavigationItem () {
						LeftBarButtonItem = _leftBarButtonItem,
						RightBarButtonItem = _rightBarButtonItem,
					};

                    
					_navigationBar.SetItems (
						new UINavigationItem[] { navItem }, false
					);
					_navigationBar.ClipsToBounds = false;
                    
					_buttonItemHandler = new ECLSPopoverButtonItemHandler (
						navItem.LeftBarButtonItem, navItem.RightBarButtonItem
					);
					_buttonItemHandler.NotifyComplete = this.NotifyComplete;

					this.View.AddSubview (_navigationBar);

					this.View.AddSubview (
						new UIView (CGRect.FromLTRB (0, _navigationBar.Frame.Height, this.View.Bounds.Right, this.View.Bounds.Bottom)) {

							BackgroundColor = UIColor.FromRGB (240, 232, 236),
							Alpha = .95f
						}
					);	
					/*this.View.AddSubview(
						new UIImageView(UIImage.FromFile(@"Images/Background_Calculating_Full.png").StretchableImage(0, 5)) {
							Frame = RectangleF.FromLTRB(0, _navigationBar.Frame.Height, this.View.Bounds.Right, this.View.Bounds.Bottom)
						}
					);	*/										
				} else if (_style == ECLSPopoverStyle.Activity) {
						
					/*this.View.AddSubview(
						new UIImageView(UIImage.FromFile(@"Images/Background_Calculating_Full.png").StretchableImage(0, 5)) {
							Frame = this.View.Bounds
						}
					);
					
*/
					this.View.AddSubview (new UIView (this.View.Bounds) {
						BackgroundColor = UIColor.Black, 
						//BackgroundColor =  UIColor.FromRGB (175,1,83),  //magenta
						Alpha = .75f
					});
					
					_activityLabel = new UILabel () {
						Frame = CGRect.FromLTRB (this.View.Frame.Left, (_frameHeight / 2), this.View.Frame.Width, (_frameHeight / 2) + 31 /* adjusted below */),
						TextAlignment = UITextAlignment.Center,
						Lines = 3,
						LineBreakMode = UILineBreakMode.WordWrap,
						BackgroundColor = UIColor.Clear,
						Opaque = true,
						TextColor = UIColor.White,
						Text = this.Title,
						ShadowColor = UIColor.Black,
						ShadowOffset = new CGSize (0f, -1.0f),
						Font = ECLSUIUtil.HelveticaNeueBold (24.0f)
					};					
					CGSize labelSize = ECLSUIUtil.LabelRequiredSize (_activityLabel, this.Title);
					_activityLabel.Frame = CGRect.FromLTRB (
						_activityLabel.Frame.Left, _activityLabel.Frame.Top, _activityLabel.Frame.Right, _activityLabel.Frame.Top + labelSize.Height
					);
					this.View.AddSubview (_activityLabel);
			
					_activityIndicator = new UIActivityIndicatorView () {
						HidesWhenStopped = true,
						Center = new CGPoint (
							this.View.Frame.Width / 2, (_frameHeight / 2) - 20
						)
					};
					this.View.AddSubview (_activityIndicator);

					_activityIndicator.StartAnimating ();
				} else if (_style == ECLSPopoverStyle.Plain) {
								
					_activityLabel = new UILabel () {
						Frame = CGRect.FromLTRB (this.View.Frame.Left, (_frameHeight / 2), this.View.Frame.Width, (_frameHeight / 2) + 31 /* adjusted below */),
						TextAlignment = UITextAlignment.Center,
						Lines = 3,
						LineBreakMode = UILineBreakMode.WordWrap,
						BackgroundColor = UIColor.Clear,
						Opaque = true,
						TextColor = UIColor.White,
						Text = this.Title,
						ShadowColor = UIColor.Black,
						ShadowOffset = new CGSize (0f, -1.0f),
						Font = ECLSUIUtil.HelveticaNeueBold (18.0f)
					};					
					CGSize labelSize = ECLSUIUtil.LabelRequiredSize (_activityLabel, this.Title);
					_activityLabel.Frame = CGRect.FromLTRB (
						_activityLabel.Frame.Left, _activityLabel.Frame.Top, _activityLabel.Frame.Right, _activityLabel.Frame.Top + labelSize.Height
					);
					this.View.AddSubview (_activityLabel);

					_activityIndicator = new UIActivityIndicatorView () {
						HidesWhenStopped = true,
						Center = new CGPoint (
							this.View.Frame.Width / 2, (_frameHeight / 2) - 20
						)
					};
					this.View.AddSubview (_activityIndicator);

					_activityIndicator.StartAnimating ();
				}
			});
		
		}