Пример #1
0
 /// <summary>
 /// Apply this theme to a specific view.
 /// </summary>
 /// <param name="options">
 /// "blue", or null
 /// </para>
 public static void Apply(UIBarButtonItem view, string options = null)
 {
     if (options == "blue")
     {
         view.SetBackgroundImage(blueBarButtonBackground.Value, UIControlState.Normal, UIBarMetrics.Default);
         view.SetBackButtonBackgroundImage(blueBackButtonBackBackground.Value, UIControlState.Normal, UIBarMetrics.Default);
     }
     else
     {
         view.SetBackgroundImage(barButtonBackground.Value, UIControlState.Normal, UIBarMetrics.Default);
         view.SetBackButtonBackgroundImage(backButtonBackBackground.Value, UIControlState.Normal, UIBarMetrics.Default);
     }
 }
Пример #2
0
        public static void SetBarButtonItemAppearance(UIBarButtonItem.UIBarButtonItemAppearance appearance, UIColor color, UIColor highlightedColor, UIColor textColor, float cornerRadius, float borderWidth)
        {
            UIImage backButtonPortraitImage = FlatUI.BackButtonImage(color,
                                                                     UIBarMetrics.Default,
                                                                     cornerRadius,
                                                                     color.Darken(2),
                                                                     borderWidth);
            UIImage highlightedBackButtonPortraitImage = FlatUI.BackButtonImage(highlightedColor,
                                                                                UIBarMetrics.Default,
                                                                                cornerRadius,
                                                                                highlightedColor.Darken(2),
                                                                                borderWidth);
            UIImage backButtonLandscapeImage = FlatUI.BackButtonImage(color,
                                                                      UIBarMetrics.LandscapePhone,
                                                                      cornerRadius,
                                                                      color.Darken(2),
                                                                      borderWidth);
            UIImage highlightedBackButtonLandscapeImage = FlatUI.BackButtonImage(highlightedColor,
                                                                                 UIBarMetrics.LandscapePhone,
                                                                                 cornerRadius,
                                                                                 highlightedColor.Darken(2),
                                                                                 borderWidth);

            appearance.SetBackButtonBackgroundImage(backButtonPortraitImage, UIControlState.Normal, UIBarMetrics.Default);
            appearance.SetBackButtonBackgroundImage(backButtonLandscapeImage, UIControlState.Normal, UIBarMetrics.LandscapePhone);
            appearance.SetBackButtonBackgroundImage(highlightedBackButtonPortraitImage, UIControlState.Highlighted, UIBarMetrics.Default);
            appearance.SetBackButtonBackgroundImage(highlightedBackButtonLandscapeImage, UIControlState.Highlighted, UIBarMetrics.LandscapePhone);

            appearance.SetBackButtonTitlePositionAdjustment(new UIOffset(1f, 1f), UIBarMetrics.Default);
            appearance.SetBackButtonTitlePositionAdjustment(new UIOffset(1f, 1f), UIBarMetrics.LandscapePhone);

            UIImage buttonImageNormal = FlatUI.Image(color, cornerRadius, color.Darken(2), borderWidth);
            UIImage buttonImageHighlighted = FlatUI.Image(highlightedColor, cornerRadius, highlightedColor.Darken(2), borderWidth);

            appearance.SetBackgroundImage(buttonImageNormal, UIControlState.Normal, UIBarMetrics.Default);
            appearance.SetBackgroundImage(buttonImageHighlighted, UIControlState.Highlighted, UIBarMetrics.Default);

            UITextAttributes titleTextAttributes = appearance.GetTitleTextAttributes(UIControlState.Normal);
            if (titleTextAttributes == null)
                titleTextAttributes = new UITextAttributes();
            titleTextAttributes.TextShadowColor = UIColor.Clear;
            titleTextAttributes.TextShadowOffset = new UIOffset(0, 0);
            titleTextAttributes.TextColor = textColor;
            titleTextAttributes.Font = FlatUI.FontOfSize(0);
            appearance.SetTitleTextAttributes(titleTextAttributes, UIControlState.Normal);
            appearance.SetTitleTextAttributes(titleTextAttributes, UIControlState.Highlighted);
        }
Пример #3
0
        public void BackButtonBackgroundImage()
        {
            using (UIBarButtonItem btn = new UIBarButtonItem()) {
#if !__TVOS__
                Assert.Null(btn.GetBackButtonBackgroundImage(UIControlState.Highlighted, UIBarMetrics.Default), "Get");
                btn.SetBackButtonBackgroundImage(null, UIControlState.Highlighted, UIBarMetrics.Default);
#endif
            }
        }
Пример #4
0
		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
 /// <summary>
 /// Apply this theme to all views with the given appearance.
 /// </summary>
 /// <param name="options">
 /// "blue", or null
 /// </para>
 public static void Apply(UIBarButtonItem.UIBarButtonItemAppearance appearance, string options = null)
 {
     if (options == "blue") {
         appearance.SetBackgroundImage (blueBarButtonBackground.Value, UIControlState.Normal, UIBarMetrics.Default);
         appearance.SetBackButtonBackgroundImage (blueBackButtonBackBackground.Value, UIControlState.Normal, UIBarMetrics.Default);
     } else {
         appearance.SetBackgroundImage (barButtonBackground.Value, UIControlState.Normal, UIBarMetrics.Default);
         appearance.SetBackButtonBackgroundImage (backButtonBackBackground.Value, UIControlState.Normal, UIBarMetrics.Default);
     }
 }