コード例 #1
0
ファイル: Theme.cs プロジェクト: tranuydu/prebuilt-apps
 /// <summary>
 /// Apply this theme to a specific view.
 /// </summary>
 /// <param name="options">
 /// "blue", or null
 /// </para>
 public static void Apply(UINavigationBar view, string options = null)
 {
     if (options == "blue")
         view.SetBackgroundImage (blueNavigationBarBackground.Value, UIBarMetrics.Default);
     else
         view.SetBackgroundImage (navigationBarBackground.Value, UIBarMetrics.Default);
 }
コード例 #2
0
        public static void SetupStyle(this UINavigationBar view, Models.ThemeConfigs.NavigationBar model)
        {
            view.BarTintColor = model.BackgroundColor.ToUIColor();
            view.TintColor    = model.TintColor.ToUIColor();

            if (UIDevice.CurrentDevice.CheckSystemVersion(11, 0))
            {
                view.PrefersLargeTitles = model.PrefersLargeTitles;

                if (model.LargeTitle != null && view.PrefersLargeTitles)
                {
                    view.LargeTitleTextAttributes = new UIStringAttributes
                    {
                        Font              = (UIFont)model.LargeTitle.Font ?? UIFont.GetPreferredFontForTextStyle(UIFontTextStyle.LargeTitle),
                        ForegroundColor   = model.LargeTitle.TextColor.ToUIColor(),
                        KerningAdjustment = model.LargeTitle.Kerning ?? 0
                    }
                }
                ;

                view.Opaque      = model.Opaque;
                view.Translucent = model.Translucent;

                if (!model.Translucent)
                {
                    view.SetBackgroundImage(model.BackgroundColor.ToUIImage(), UIBarPosition.Any, UIBarMetrics.Default);
                    view.ShadowImage = model.BackgroundColor.ToUIImage();
                }
                else
                {
                    view.BackgroundColor = model.BackgroundColor.ToUIColor();
                    view.ShadowImage     = new UIImage();
                    view.SetBackgroundImage(null, UIBarMetrics.Default);
                }
            }
            else
            {
                view.SetBackgroundImage(model.BackgroundColor.ToUIImage(), UIBarPosition.Any, UIBarMetrics.Default);
                view.ShadowImage = model.BackgroundColor.ToUIImage();
                view.Translucent = false;
                view.Opaque      = false;
            }

            if (model.Title != null)
            {
                view.TitleTextAttributes = new UIStringAttributes
                {
                    Font              = (UIFont)model.Title.Font,
                    ForegroundColor   = model.Title.TextColor.ToUIColor(),
                    KerningAdjustment = model.Title.Kerning ?? 0
                }
            }
            ;
        }
    }
}
コード例 #3
0
 /// <summary>
 /// Apply this theme to a specific view.
 /// </summary>
 /// <param name="options">
 /// "blue", or null
 /// </para>
 public static void Apply(UINavigationBar view, string options = null)
 {
     if (options == "blue")
     {
         view.SetBackgroundImage(blueNavigationBarBackground.Value, UIBarMetrics.Default);
     }
     else
     {
         view.SetBackgroundImage(navigationBarBackground.Value, UIBarMetrics.Default);
     }
 }
コード例 #4
0
		private void SetSessionBackground (UINavigationBar navigationBar)
		{
			var version = Convert.ToDecimal (UIDevice.CurrentDevice.SystemVersion.Split ('.').First ());

			if (version >= 7) {
				navigationBar.SetBackgroundImage (UIImage.FromFile ("images/SessionsHeader3.png"), UIBarMetrics.Default);
			} else if (version >= 5) {
				navigationBar.SetBackgroundImage (UIImage.FromFile ("images/SessionsHeader2.png"), UIBarMetrics.Default);
			} else {
				navigationBar.InsertSubview (new UIImageView (UIImage.FromFile ("images/SessionsHeader2.png")), 0);
			}
		}
コード例 #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 (UINavigationBar.UINavigationBarAppearance appearance, string options = null)
		{
			if (options == "blue")
				appearance.SetBackgroundImage (blueNavigationBarBackground.Value, UIBarMetrics.Default);
			else
				appearance.SetBackgroundImage (navigationBarBackground.Value, UIBarMetrics.Default);

			appearance.SetTitleTextAttributes (new UITextAttributes {
				TextColor = UIColor.FromRGBA (255, 255, 255, 255),
				TextShadowColor = UIColor.FromRGBA (0, 0, 0, 0.8f),
				TextShadowOffset = new UIOffset (0, -1)
			});
		}
コード例 #6
0
 /// <summary>
 /// Apply this theme to a specific view.
 /// </summary>
 /// <param name="options">
 /// "blue", or null
 /// </para>
 public static void Apply(UINavigationBar view, string options = null)
 {
     if (options == "blue")
     {
         view.SetBackgroundImage(blueNavigationBarBackground.Value, UIBarMetrics.Default);
     }
     else
     {
         view.SetBackgroundImage(navigationBarBackground.Value, UIBarMetrics.Default);
     }
     view.SetTitleTextAttributes(new UITextAttributes {
         TextColor        = UIColor.FromRGBA(255, 255, 255, 255),
         TextShadowColor  = UIColor.FromRGBA(0, 0, 0, 0.8f),
         TextShadowOffset = new UIOffset(0, -1),
     });
 }
        private void SetupTransparentNavigationBar(IList <ToolbarItem> toolbarItems)
        {
            var navBar = new UINavigationBar(new CGRect(0, 0, this.View.Bounds.Width, 60))
            {
                Translucent = true
            };

            navBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
            navBar.ShadowImage = new UIImage();

            _navbarItem = new UINavigationItem {
                LeftBarButtonItems = new UIBarButtonItem[] { }
            };
            var leftNativeButtons  = new List <Tuple <ToolbarItem, UIBarButtonItem> >();
            var rightNativeButtons = new List <Tuple <ToolbarItem, UIBarButtonItem> >();

            _navbarItem.TitleView = BuildSubTitleView(NavigationBarPage);
            CreateUIBarButtonFromToolBarItems(leftNativeButtons, rightNativeButtons, toolbarItems);

            _navbarItem.RightBarButtonItems = SetCustomFontsToToolBars(rightNativeButtons,
                                                                       NavigationBarPage.RightToolbarItemFont, NavigationBarPage.RightToolbarItemVisible);

            _navbarItem.LeftBarButtonItems = SetCustomFontsToToolBars(leftNativeButtons,
                                                                      NavigationBarPage.LeftToolbarItemFont, NavigationBarPage.LeftToolbarItemVisible);

            if (NavigationBarPage.BarTintColor != Color.Default)
            {
                navBar.TintColor = NavigationBarPage.BarTintColor.ToUIColor();
            }

            navBar.Items = new[] { _navbarItem };
            this.View.AddSubview(navBar);
        }
コード例 #8
0
 public void BackgroundImage()
 {
     // http://stackoverflow.com/q/10504966/220643
     using (UINavigationBar nb = new UINavigationBar()) {
         Assert.Null(nb.GetBackgroundImage(UIBarMetrics.Default), "Get");
         nb.SetBackgroundImage(null, UIBarMetrics.Default);
     }
 }
コード例 #9
0
        public static void SetFlatNavigationBarAppearance(UINavigationBar.UINavigationBarAppearance appearance, UIColor color, UIColor textColor)
        {
            UIImage backgroundImage = FlatUI.Image(color, 0);
            appearance.SetBackgroundImage(backgroundImage, UIBarMetrics.Default);
            appearance.SetBackgroundImage(backgroundImage, UIBarMetrics.LandscapePhone);

            UITextAttributes titleTextAttributes = appearance.GetTitleTextAttributes();
            if (titleTextAttributes == null)
                titleTextAttributes = new UITextAttributes();
            titleTextAttributes.TextShadowColor = UIColor.Clear;
            titleTextAttributes.TextShadowOffset = new UIOffset(0, 0);
            titleTextAttributes.TextColor = textColor;
            titleTextAttributes.Font = FlatUI.BoldFontOfSize(0);
            appearance.SetTitleTextAttributes(titleTextAttributes);
            if (appearance.RespondsToSelector(new MonoTouch.ObjCRuntime.Selector("setShadowImage:")))
                appearance.ShadowImage = FlatUI.Image(UIColor.Clear, 0);
        }
コード例 #10
0
ファイル: Theme.cs プロジェクト: xNUTs/CodeBucket
 private static void SetApperance(UINavigationBar.UINavigationBarAppearance bar, UIImage backgroundImg, UIColor color)
 {
     bar.TintColor = UIColor.White;
     bar.BarTintColor = bar.BackgroundColor = color;
     bar.SetBackgroundImage(backgroundImg, UIBarMetrics.Default);
     bar.SetTitleTextAttributes(new UITextAttributes { TextColor = UIColor.White, Font = UIFont.SystemFontOfSize(18f) });
     bar.BackIndicatorImage = Images.Buttons.Back;
     bar.BackIndicatorTransitionMaskImage = Images.Buttons.Back;
 }
コード例 #11
0
        private void InitializeControls()
        {
            this.View.BackgroundColor = UIColor.FromPatternImage(UIImage.FromBundle("Assets/Backgrounds/background_portrait.png"));
            this.View.Frame           = new CGRect(0, 0, FRAME_WIDTH, FRAME_HEIGHT);

            // navBar
            UIImage navImage = UIImage.FromBundle("Assets/Backgrounds/topBar.png").CreateResizableImage(new UIEdgeInsets(0, 22, 0, 22));

            navBar = new UINavigationBar(new CGRect(0, 0, this.View.Frame.Width, 44));
            navBar.TitleTextAttributes = new UIStringAttributes()
            {
                ForegroundColor = UIColor.White
            };
            navBar.TintColor = UIColor.White;
            navBar.SetBackgroundImage(navImage, UIBarMetrics.Default);
            this.View.AddSubview(navBar);

            // doneButton
            UINavigationItem item = new UINavigationItem();

            item.Title = "Privacy Policy";
            item.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, HandleCloseButtonTouchUpInside);
            navBar.PushNavigationItem(item, false);

            // scrollView
            scrollView = new UIScrollView(new CGRect(0, navBar.Frame.Bottom, this.View.Frame.Width, this.View.Frame.Height - 44));
            scrollView.BackgroundColor = UIColor.Clear;
            this.View.AddSubview(scrollView);

            // webView
            webView        = new UIWebView(new CGRect(15, 15, scrollView.Frame.Width - 30, scrollView.Frame.Height - 30));
            webView.Alpha  = 0f;
            webView.Opaque = false;

            CustomWebViewDelegate customDelegate = new CustomWebViewDelegate();

            customDelegate.LoadFinishedEvent += HandleLoadFinishedEvent;
            webView.Delegate        = customDelegate;
            webView.BackgroundColor = UIColor.Clear;

            foreach (var sv in webView.Subviews)
            {
                if (sv is UIScrollView)
                {
                    ((UIScrollView)sv).Bounces = false;
                }
            }
            scrollView.AddSubview(webView);
        }
コード例 #12
0
        private static void setNavigationBarAttributes(UINavigationBar navBar)
        {
            if (navBar == null)
            {
                return;
            }

            navBar.BarStyle    = UIBarStyle.Black;
            navBar.ShadowImage = new UIImage();
            navBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
            navBar.TitleTextAttributes = new UIStringAttributes
            {
                ForegroundColor = UIColor.White,
                Font            = UIFont.SystemFontOfSize(14, UIFontWeight.Medium)
            };
        }
コード例 #13
0
        internal ViewControllerNavigationBar(UINavigationBar navigationBar, EventHandler previousButtonTapped, EventHandler restartButtonTapped)
        {
            this.navigationBar = navigationBar;

            backButton      = new UIBarButtonItem("Back", UIBarButtonItemStyle.Plain, previousButtonTapped);
            startOverButton = new UIBarButtonItem("Restart", UIBarButtonItemStyle.Plain, restartButtonTapped);

            var navigationItem = new UINavigationItem("Start");

            navigationItem.LeftBarButtonItem  = backButton;
            navigationItem.RightBarButtonItem = startOverButton;
            navigationBar.Items = new[] { navigationItem };

            navigationBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);
            navigationBar.ShadowImage = new UIImage();
            navigationBar.Translucent = true;
        }
コード例 #14
0
        void SetUpNavigationBar()
        {
            NavigationBar = new UINavigationBar();
            NavigationBar.TranslatesAutoresizingMaskIntoConstraints = false;

            NavigationBar.BackgroundColor = UIColor.Clear;
            NavigationBar.BarTintColor    = null;
            NavigationBar.Translucent     = true;
            NavigationBar.ShadowImage     = new UIImage();
            NavigationBar.SetBackgroundImage(new UIImage(), UIBarMetrics.Default);

            NavigationItem      = new UINavigationItem("");
            NavigationBar.Items = new[] { NavigationItem };

            AddSubview(NavigationBar);

            var topConstraint   = NSLayoutConstraint.Create(NavigationBar, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1.0f, 0.0f);
            var widthConstraint = NSLayoutConstraint.Create(NavigationBar, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 1.0f, 0.0f);
            var horizontalPositionConstraint = NSLayoutConstraint.Create(NavigationBar, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterX, 1.0f, 0.0f);

            AddConstraints(new[] { topConstraint, widthConstraint, horizontalPositionConstraint });
        }