Esempio n. 1
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            FBSettings.DefaultAppID       = AppId;
            FBSettings.DefaultDisplayName = DisplayName;
            // create a new window instance based on the screen size
            window = new UIWindow(UIScreen.MainScreen.Bounds);
            rootNavigationController = new UINavigationController();
            CAGradientLayer degradado = new CAGradientLayer();

            degradado.Frame = (rootNavigationController.NavigationBar.Bounds);
            UIGraphics.BeginImageContext(rootNavigationController.NavigationBar.Bounds.Size);
            degradado.Colors = new CGColor[] { UIColor.FromRGB(62, 92, 41).CGColor, UIColor.FromRGB(132, 194, 71).CGColor };
            degradado.RenderInContext(UIGraphics.GetCurrentContext());
            UIImage bgDegradado = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();
            rootNavigationController.NavigationBar.TintColor = UIColor.White;
            UIStringAttributes atributes = new UIStringAttributes();

            atributes.ForegroundColor = UIColor.White;
            rootNavigationController.NavigationBar.TitleTextAttributes = atributes;

            rootNavigationController.NavigationBar.SetBackgroundImage(bgDegradado, UIBarMetrics.Default);

            // If you have defined a root view controller, set it here:
            // window.RootViewController = myViewController;
            mainView = new MainView();
            rootNavigationController.PushViewController(mainView, false);

            // make the window visible
            window.RootViewController = rootNavigationController;
            window.MakeKeyAndVisible();

            return(true);
        }
Esempio n. 2
0
		//
		// This method is invoked when the application has loaded and is ready to run. In this
		// method you should instantiate the window, load the UI into it and then make the window
		// visible.
		//
		// You have 17 seconds to return from this method, or iOS will terminate your application.
		//
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{

			FBSettings.DefaultAppID = AppId;
			FBSettings.DefaultDisplayName = DisplayName;
			// create a new window instance based on the screen size
			window = new UIWindow (UIScreen.MainScreen.Bounds);
			rootNavigationController = new UINavigationController ();
			CAGradientLayer degradado = new CAGradientLayer ();
			degradado.Frame = (rootNavigationController.NavigationBar.Bounds);
			UIGraphics.BeginImageContext (rootNavigationController.NavigationBar.Bounds.Size);
			degradado.Colors = new CGColor[] { UIColor.FromRGB (62, 92, 41).CGColor, UIColor.FromRGB (132, 194, 71).CGColor };
			degradado.RenderInContext (UIGraphics.GetCurrentContext());
			UIImage bgDegradado = UIGraphics.GetImageFromCurrentImageContext ();
			UIGraphics.EndImageContext ();
			rootNavigationController.NavigationBar.TintColor = UIColor.White;
			UIStringAttributes atributes = new UIStringAttributes();
			atributes.ForegroundColor = UIColor.White;
			rootNavigationController.NavigationBar.TitleTextAttributes = atributes;

			rootNavigationController.NavigationBar.SetBackgroundImage (bgDegradado, UIBarMetrics.Default);

			// If you have defined a root view controller, set it here:
			// window.RootViewController = myViewController;
			mainView = new MainView ();
			rootNavigationController.PushViewController (mainView,false);

			// make the window visible
			window.RootViewController = rootNavigationController;
			window.MakeKeyAndVisible ();
			
			return true;
		}
Esempio n. 3
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();


            var gradientLayer = new CAGradientLayer();

            gradientLayer.Bounds     = UIScreen.MainScreen.Bounds;
            gradientLayer.Colors     = new CGColor[] { Color.FromHex("#7C3F85").ToCGColor(), Color.FromHex("#E7854B").ToCGColor() };
            gradientLayer.StartPoint = new CGPoint(0.0, 0.5);
            gradientLayer.EndPoint   = new CGPoint(1.0, 0.5);

            UIGraphics.BeginImageContext(gradientLayer.Bounds.Size);
            gradientLayer.RenderInContext(UIGraphics.GetCurrentContext());
            UIImage image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            UINavigationBar.Appearance.TintColor = Color.White.ToUIColor();
            UINavigationBar.Appearance.SetBackgroundImage(image, UIBarMetrics.Default);


            //UINavigationBar.Appearance.SetBackgroundImage(UIImage.FromFile("xamarin_logo"), UIBarMetrics.Default);
            LoadApplication(new App());



            return(base.FinishedLaunching(app, options));
        }
Esempio n. 4
0
        private UIImage GetGradientImage(nfloat width, CGSize size, CGColor[] colors)
        {
            var gradientLayer = new CAGradientLayer();

            gradientLayer.Frame         = new CGRect(0, 0, width, size.Height);
            gradientLayer.CornerRadius  = gradientLayer.Frame.Height / 2;
            gradientLayer.MasksToBounds = true;
            gradientLayer.Colors        = colors;
            gradientLayer.StartPoint    = new CGPoint(x: 0.0, y: 0.5);
            gradientLayer.EndPoint      = new CGPoint(x: 1.0, y: 0.5);

            if (control.HasSegment)
            {
                var segmentDelay = (size.Width - 10) / (Element.Maximum / control.Interval);

                for (int i = 0; i <= Element.Maximum / control.Interval; i++)
                {
                    var segmentLayer = new CALayer();
                    var myImage      = i * control.Interval < Control.Value ? new UIImage(control.MaxIntervaImageSource) : new UIImage(control.MinIntervaImageSource);
                    segmentLayer.Contents = myImage.CGImage;
                    segmentLayer.Frame    = new CGRect(i == 0 ? 10 : segmentDelay * i, (size.Height - 5) / 2, 5, 5);
                    gradientLayer.AddSublayer(segmentLayer);
                }
            }

            UIGraphics.BeginImageContextWithOptions(size, gradientLayer.Opaque, 0.0f);
            var context = UIGraphics.GetCurrentContext();

            gradientLayer.RenderInContext(context);
            var image = UIGraphics.GetImageFromCurrentImageContext().CreateResizableImage(new UIEdgeInsets(top: 0, left: size.Height, bottom: 0, right: size.Height));

            UIGraphics.EndImageContext();
            return(image);
        }
Esempio n. 5
0
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            MyNavigationPageRenderer myNavigationPageRenderer = (MyNavigationPageRenderer)this.Element;

            var gradientLayer = new CAGradientLayer();

            gradientLayer.Bounds = NavigationBar.Bounds;
            gradientLayer.Colors = new CGColor[] {
                myNavigationPageRenderer.StartColor.ToCGColor(),
                    myNavigationPageRenderer.EndColor.ToCGColor()
            };
            gradientLayer.StartPoint = new CGPoint(0.0, 0.5);
            gradientLayer.EndPoint   = new CGPoint(1.0, 0.5);

            UIGraphics.BeginImageContext(gradientLayer.Bounds.Size);
            gradientLayer.RenderInContext(UIGraphics.GetCurrentContext());
            UIImage image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            NavigationBar.ShadowImage = new UIImage();
            NavigationBar.SetBackgroundImage(image, UIBarMetrics.Default);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();


            var gradientLayer = new CAGradientLayer();

            gradientLayer.NeedsDisplayOnBoundsChange = true;

            var b = NavigationBar.Bounds;

            gradientLayer.Bounds = new CGRect(b.X, b.Y, b.Width, b.Height + 20);

            gradientLayer.Colors = new CGColor[] { Color.FromHex("#60C3FF").ToCGColor(),
                                                   Color.FromHex("#5574F7").ToCGColor() };

            float x1 = 0f, x2 = 1f, y1 = 0f, y2 = 1f;

            x1 = x2 = 0.5f;
            gradientLayer.StartPoint = new CGPoint(x1, y1);
            gradientLayer.EndPoint   = new CGPoint(x2, y2);

            UIGraphics.BeginImageContext(gradientLayer.Bounds.Size);
            gradientLayer.RenderInContext(UIGraphics.GetCurrentContext());
            UIImage image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            NavigationBar.SetBackgroundImage(image, UIBarMetrics.Default);
        }
Esempio n. 7
0
        public static UIImage GetGradient(CGRect area)
        {
            var gradient = new CAGradientLayer();

            gradient.Frame = area;
            gradient.NeedsDisplayOnBoundsChange = true;
            gradient.MasksToBounds = true;
            gradient.StartPoint    = new CGPoint(0, 0);
            gradient.EndPoint      = new CGPoint(1, 0);
            gradient.Colors        = new CGColor[] { PrimaryColor.CGColor, SecondaryColor.CGColor };
            UIGraphics.BeginImageContext(gradient.Bounds.Size);
            gradient.RenderInContext(UIGraphics.GetCurrentContext());
            UIImage backImage = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();
            return(backImage);
        }
Esempio n. 8
0
        void UpdateGradientView()
        {
            var gradientLayer = new CAGradientLayer
            {
                Bounds     = NavigationBar.Bounds,
                Colors     = new CGColor[] { Colors.Blue.ToCGColor(), Colors.Purple.ToCGColor() },
                EndPoint   = new CGPoint(0.0, 0.5),
                StartPoint = new CGPoint(1.0, 0.5)
            };

            UIGraphics.BeginImageContext(gradientLayer.Bounds.Size);
            gradientLayer.RenderInContext(UIGraphics.GetCurrentContext());
            UIImage image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();
            NavigationBar.SetBackgroundImage(image, UIBarMetrics.Default);
        }
Esempio n. 9
0
	    public static UIImage GetGradientImage(CGColor startColor, CGColor endColor, CGSize size)
	    {
            UIGraphics.BeginImageContext(size);
            var context = UIGraphics.GetCurrentContext();
			if (context != null) {
				var gradientLayer = new CAGradientLayer();
				gradientLayer.Frame = new CGRect(0, 0, size.Width, size.Height);
				gradientLayer.Colors = new CGColor[] { startColor, endColor };
				gradientLayer.RenderInContext(context);
				UIImage gradientImage = UIGraphics.GetImageFromCurrentImageContext();
				UIGraphics.EndImageContext();

				return gradientImage;
			}

			return null;
	    }
        void CreateBorder()
        {
            var direction = button.Angle.ToiOS();

            var gradient = new CAGradientLayer();

            gradient.StartPoint = direction[0];
            gradient.EndPoint   = direction[1];
            gradient.Frame      = new CGRect(0, 0, button.Width, button.Height);
            gradient.Colors     = new[] { button.StartColor.ToCGColor(), button.CenterColor.ToCGColor(), button.EndColor.ToCGColor() };

            var shape = new CAShapeLayer();

            shape.LineWidth   = (float)button.BorderWidth;
            shape.Path        = UIBezierPath.FromRect(new CGRect(0, 0, button.Width, button.Height)).CGPath;
            shape.StrokeColor = UIColor.Black.CGColor;
            shape.FillColor   = UIColor.Clear.CGColor;
            gradient.Mask     = shape;

            nButton.Layer.AddSublayer(gradient);


            var gradientText = new CAGradientLayer();

            gradientText.StartPoint = direction[0];
            gradientText.EndPoint   = direction[1];
            gradientText.Colors     = new [] { button.StartColor.ToCGColor(), button.CenterColor.ToCGColor(), button.EndColor.ToCGColor() };
            gradientText.Bounds     = new CGRect(0, 0, button.Width, button.Height);
            UIGraphics.BeginImageContextWithOptions(gradientText.Bounds.Size, true, (float)0.0);
            var context = UIGraphics.GetCurrentContext();

            gradientText.RenderInContext(context);
            var image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            // Create a label and add it as a subview
            var label = new UILabel(new CGRect(0, 0, button.Width, button.Height));

            label.Text          = button.Text;
            label.Font          = button.Font.ToUIFont();
            label.TextAlignment = UITextAlignment.Center;
            label.TextColor     = new UIColor(image);

            nButton.AddSubview(label);
        }
Esempio n. 11
0
        private void SetGradientBackground()
        {
            if (NavigationController != null)
            {
                var gradientLayer = new CAGradientLayer();
                gradientLayer.Bounds     = NavigationController.NavigationBar.Bounds;
                gradientLayer.Colors     = new CGColor[] { StartColor.ToCGColor(), EndColor.ToCGColor() };
                gradientLayer.StartPoint = new CGPoint(0.0, 0.5);
                gradientLayer.EndPoint   = new CGPoint(1.0, 0.5);

                UIGraphics.BeginImageContext(gradientLayer.Bounds.Size);
                gradientLayer.RenderInContext(UIGraphics.GetCurrentContext());
                UIImage image = UIGraphics.GetImageFromCurrentImageContext();
                UIGraphics.EndImageContext();

                NavigationController.NavigationBar.SetBackgroundImage(image, UIBarMetrics.Default);
            }
        }
Esempio n. 12
0
        public static UIImage GetGradientImage(CGColor startColor, CGColor endColor, CGSize size)
        {
            UIGraphics.BeginImageContext(size);
            var context = UIGraphics.GetCurrentContext();

            if (context != null)
            {
                var gradientLayer = new CAGradientLayer();
                gradientLayer.Frame  = new CGRect(0, 0, size.Width, size.Height);
                gradientLayer.Colors = new CGColor[] { startColor, endColor };
                gradientLayer.RenderInContext(context);
                UIImage gradientImage = UIGraphics.GetImageFromCurrentImageContext();
                UIGraphics.EndImageContext();

                return(gradientImage);
            }

            return(null);
        }
Esempio n. 13
0
        public UIImage CreateGradientImage(CGSize rect)
        {
            var gradientLayer = new CAGradientLayer()
            {
                StartPoint   = new CGPoint(0, 0.5),
                EndPoint     = new CGPoint(1, 0.5),
                Colors       = new CGColor[] { StartColor, CenterColor, EndColor },
                Frame        = new CGRect(0, 0, rect.Width, rect.Height),
                CornerRadius = 5.0f
            };

            UIGraphics.BeginImageContext(gradientLayer.Frame.Size);
            gradientLayer.RenderInContext(UIGraphics.GetCurrentContext());
            var image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            return(image.CreateResizableImage(UIEdgeInsets.Zero));
        }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            var gradientLayer = new CAGradientLayer();
            var barHeight     = (double)UIApplication.SharedApplication.StatusBarFrame.Height;

            gradientLayer.Bounds     = new CGRect(0, 0, NavigationBar.Bounds.Width, NavigationBar.Bounds.Height + barHeight);
            gradientLayer.Colors     = new CGColor[] { Color.FromHex("#55C500").ToCGColor(), Color.FromHex("3B8400").ToCGColor() };
            gradientLayer.StartPoint = new CGPoint(0.0, 0.5);
            gradientLayer.EndPoint   = new CGPoint(1.0, 0.5);

            UIGraphics.BeginImageContext(View.Frame.Size);
            gradientLayer.RenderInContext(UIGraphics.GetCurrentContext());
            UIImage image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();
            NavigationBar.SetBackgroundImage(image, UIBarMetrics.Default);
        }
Esempio n. 15
0
        /// <summary>
        /// Styles the navigation bar.
        /// </summary>
        public void StyleNavigationBar()
        {
            NavigationController.SetNavigationBarHidden(false, true);

            NavigationController.NavigationBarHidden     = false;
            NavigationController.NavigationBar.BarStyle  = UIBarStyle.Black;
            NavigationController.NavigationBar.TintColor = UIColor.White;

            // customise back button
            NavigationItem.SetHidesBackButton(true, false);
            NavigationItem.SetLeftBarButtonItem(new UIBarButtonItem(
                                                    UIImage.FromFile("back.png"), UIBarButtonItemStyle.Plain, (sender, args) =>
            {
                NavigationController.PopViewController(true);
            }), true);

            var gradient = new CAGradientLayer();

            gradient.Frame = NavigationController.NavigationBar.Bounds;
            gradient.NeedsDisplayOnBoundsChange = true;
            gradient.MasksToBounds = true;

            gradient.Colors = new CGColor[]
            {
                UIColor.Clear.FromHex("c14d60").CGColor,
                UIColor.Clear.FromHex("d55b5f").CGColor
            };

            UIGraphics.BeginImageContext(gradient.Bounds.Size);
            gradient.RenderInContext(UIGraphics.GetCurrentContext());
            UIImage backImage = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();
            NavigationController.NavigationBar.SetBackgroundImage(backImage, UIBarMetrics.Default);

            UITextAttributes myTextAttrib = new UITextAttributes();

            myTextAttrib.Font      = UIFont.FromName("Helvetica", 14f);
            myTextAttrib.TextColor = UIColor.FromRGB(105, 105, 105);

            UINavigationBar.Appearance.SetTitleTextAttributes(myTextAttrib);
        }
Esempio n. 16
0
        UIImage CreateGradientBackground(Color startColor, Color endColor, CustomNavigationPage.GradientDirection direction)
        {
            var gradientLayer = new CAGradientLayer();

            gradientLayer.Bounds = NavigationController.NavigationBar.Bounds;
            gradientLayer.Colors = new CGColor[] { startColor.ToCGColor(), endColor.ToCGColor() };

            switch (direction)
            {
            case CustomNavigationPage.GradientDirection.LeftToRight:
                gradientLayer.StartPoint = new CGPoint(0.0, 0.5);
                gradientLayer.EndPoint   = new CGPoint(1.0, 0.5);
                break;

            case CustomNavigationPage.GradientDirection.RightToLeft:
                gradientLayer.StartPoint = new CGPoint(1.0, 0.5);
                gradientLayer.EndPoint   = new CGPoint(0.0, 0.5);
                break;

            case CustomNavigationPage.GradientDirection.BottomToTop:
                gradientLayer.StartPoint = new CGPoint(1.0, 1.0);
                gradientLayer.EndPoint   = new CGPoint(0.0, 0.0);
                break;

            default:
                gradientLayer.StartPoint = new CGPoint(1.0, 0.0);
                gradientLayer.EndPoint   = new CGPoint(0.0, 1.0);
                break;
            }

            UIGraphics.BeginImageContext(gradientLayer.Bounds.Size);
            gradientLayer.RenderInContext(UIGraphics.GetCurrentContext());
            UIImage image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();


            return(image);
        }
        public override void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            var control = (NavigationPage)this.Element;

            control.BarTextColor = Color.White;
            var gradientLayer = new CAGradientLayer();

            gradientLayer.Bounds     = NavigationBar.Bounds;
            gradientLayer.Colors     = new CGColor[] { Color.FromHex("#1E5799").ToCGColor(), Color.FromHex("#2989D8").ToCGColor(), Color.FromHex("#1E5799").ToCGColor() };
            gradientLayer.StartPoint = new CGPoint(0.0, 0.5);
            gradientLayer.EndPoint   = new CGPoint(1.0, 0.5);

            UIGraphics.BeginImageContext(gradientLayer.Bounds.Size);
            gradientLayer.RenderInContext(UIGraphics.GetCurrentContext());
            UIImage image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            NavigationBar.SetBackgroundImage(image, UIBarMetrics.Default);
        }
Esempio n. 18
0
        private void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            if (e.PropertyName == MyContentPageRenderer.OrientationProperty.PropertyName)
            {
                MyNavigationPageRenderer myNavigationPageRenderer = (MyNavigationPageRenderer)this.Element;

                var gradientLayer = new CAGradientLayer();
                gradientLayer.Bounds = NavigationBar.Bounds;
                gradientLayer.Colors = new CGColor[] {
                    myNavigationPageRenderer.StartColor.ToCGColor(),
                        myNavigationPageRenderer.EndColor.ToCGColor()
                };
                gradientLayer.StartPoint = new CGPoint(0.0, 0.5);
                gradientLayer.EndPoint   = new CGPoint(1.0, 0.5);

                UIGraphics.BeginImageContext(gradientLayer.Bounds.Size);
                gradientLayer.RenderInContext(UIGraphics.GetCurrentContext());
                UIImage image = UIGraphics.GetImageFromCurrentImageContext();
                UIGraphics.EndImageContext();

                NavigationBar.ShadowImage = new UIImage();
                NavigationBar.SetBackgroundImage(image, UIBarMetrics.Default);
            }
        }
        private void SetGradientBackground()
        {
            var control = (GradientNavigationPage)this.Element;

            var gradientLayer = new CAGradientLayer();

            switch (control.Direction)
            {
            default:
            case GradientDirection.ToRight:
                gradientLayer.StartPoint = new CGPoint(0, 0.5);
                gradientLayer.EndPoint   = new CGPoint(1, 0.5);
                break;

            case GradientDirection.ToLeft:
                gradientLayer.StartPoint = new CGPoint(1, 0.5);
                gradientLayer.EndPoint   = new CGPoint(0, 0.5);
                break;

            case GradientDirection.ToTop:
                gradientLayer.StartPoint = new CGPoint(0.5, 0);
                gradientLayer.EndPoint   = new CGPoint(0.5, 1);
                break;

            case GradientDirection.ToBottom:
                gradientLayer.StartPoint = new CGPoint(0.5, 1);
                gradientLayer.EndPoint   = new CGPoint(0.5, 0);
                break;

            case GradientDirection.ToTopLeft:
                gradientLayer.StartPoint = new CGPoint(1, 0);
                gradientLayer.EndPoint   = new CGPoint(0, 1);
                break;

            case GradientDirection.ToTopRight:
                gradientLayer.StartPoint = new CGPoint(0, 1);
                gradientLayer.EndPoint   = new CGPoint(1, 0);
                break;

            case GradientDirection.ToBottomLeft:
                gradientLayer.StartPoint = new CGPoint(1, 1);
                gradientLayer.EndPoint   = new CGPoint(0, 0);
                break;

            case GradientDirection.ToBottomRight:
                gradientLayer.StartPoint = new CGPoint(0, 0);
                gradientLayer.EndPoint   = new CGPoint(1, 1);
                break;
            }

            // --> Get StatusBarFrame size:
            var statusBarSize = UIApplication.SharedApplication.StatusBarFrame.Size;

            // --> Set Height and Width of StatusBarFrame size:
            var statusBar = Math.Min(statusBarSize.Height, statusBarSize.Width);

            // --> Set NavigationBar Bounds:
            var navigationBarBounds = new CGRect(
                NavigationBar.Bounds.X,
                NavigationBar.Bounds.Y,
                NavigationBar.Bounds.Width,
                statusBar + NavigationBar.Bounds.Height);

            gradientLayer.Bounds = navigationBarBounds;
            gradientLayer.Colors = new CGColor[] { control.StartColor.ToCGColor(), control.EndColor.ToCGColor() };
            UIGraphics.BeginImageContext(gradientLayer.Bounds.Size);
            gradientLayer.RenderInContext(UIGraphics.GetCurrentContext());
            UIImage image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            NavigationBar.SetBackgroundImage(image, UIBarMetrics.Default);

            // --> To Change Navigation Bar Icon Color:
            NavigationBar.TintColor = Color.White.ToUIColor();

            // --> Hide Navigation Bar Separator:
            //NavigationBar.ShadowImage = new UIImage();
        }
        private void SetGradientBackground()
        {
            var control = (GradientTabbedPage)this.Element;

            var gradientLayer = new CAGradientLayer();

            switch (control.TabBarDirection)
            {
            default:
            case GradientDirection.ToRight:
                gradientLayer.StartPoint = new CGPoint(0, 0.5);
                gradientLayer.EndPoint   = new CGPoint(1, 0.5);
                break;

            case GradientDirection.ToLeft:
                gradientLayer.StartPoint = new CGPoint(1, 0.5);
                gradientLayer.EndPoint   = new CGPoint(0, 0.5);
                break;

            case GradientDirection.ToTop:
                gradientLayer.StartPoint = new CGPoint(0.5, 0);
                gradientLayer.EndPoint   = new CGPoint(0.5, 1);
                break;

            case GradientDirection.ToBottom:
                gradientLayer.StartPoint = new CGPoint(0.5, 1);
                gradientLayer.EndPoint   = new CGPoint(0.5, 0);
                break;

            case GradientDirection.ToTopLeft:
                gradientLayer.StartPoint = new CGPoint(1, 0);
                gradientLayer.EndPoint   = new CGPoint(0, 1);
                break;

            case GradientDirection.ToTopRight:
                gradientLayer.StartPoint = new CGPoint(0, 1);
                gradientLayer.EndPoint   = new CGPoint(1, 0);
                break;

            case GradientDirection.ToBottomLeft:
                gradientLayer.StartPoint = new CGPoint(1, 1);
                gradientLayer.EndPoint   = new CGPoint(0, 0);
                break;

            case GradientDirection.ToBottomRight:
                gradientLayer.StartPoint = new CGPoint(0, 0);
                gradientLayer.EndPoint   = new CGPoint(1, 1);
                break;
            }
            gradientLayer.Bounds = TabBar.Bounds;
            gradientLayer.Colors = new CGColor[] { control.TabBarStartColor.ToCGColor(), control.TabBarEndColor.ToCGColor() };
            UIGraphics.BeginImageContext(gradientLayer.Frame.Size);
            CGContext currentContext = UIGraphics.GetCurrentContext();

            gradientLayer.RenderInContext(currentContext);
            UIImage image = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            // --> Space adjustment from ()top/left/bottom/right) for Icon and (horizontal/vertical) for Title
            foreach (var tabbarItem in TabBar.Items)
            {
                // --> Leave some space from Top of Icon. UIEdgeInsets(top, left, bottom, right)
                tabbarItem.ImageInsets = new UIEdgeInsets(6, 0, 0, 0);

                // --> Leave some space from Top and Bottom of Title. UIOffset(horizontal, vertical)
                tabbarItem.TitlePositionAdjustment = new UIOffset(0, 6);
            }

            TabBar.BackgroundImage = image;

            // --> Hide TabBar Separator:
            //TabBar.ShadowImage = new UIImage();
        }