Ejemplo n.º 1
0
        protected override void OnAppearing()
        {
            base.OnAppearing();

            var layout = new RelativeLayout();

            var border1 = new RoundCornerView {
                BackgroundColor = Color.Red,
                CornerRadius    = 4,
            };

            var border2 = new RoundCornerView {
                BackgroundColor = Color.Blue,
                CornerRadius    = 14,
            };

            var border3 = new RoundCornerView {
                BackgroundColor = Color.Green,
                CornerRadius    = 12,
            };

            var border4 = new RoundCornerView {
                BackgroundColor = Color.Yellow,
                CornerRadius    = 42,
            };

            layout.Children.Add(border1, () => new Rectangle(10, 10, (layout.Width / 2) - 20, (layout.Height / 2) - 20));
            layout.Children.Add(border2, () => new Rectangle((layout.Width / 2) + 10, 10, (layout.Width / 2) - 20, (layout.Height / 2) - 20));
            layout.Children.Add(border3, () => new Rectangle(10, (layout.Height / 2) + 10, (layout.Width / 2) - 20, (layout.Height / 2) - 20));
            layout.Children.Add(border4, () => new Rectangle((layout.Width / 2) + 10, (layout.Height / 2) + 10, (layout.Width / 2) - 20, (layout.Height / 2) - 20));

            Content = layout;
        }
		protected override void OnAppearing ()
		{
			base.OnAppearing ();
		
			var layout = new RelativeLayout ();

			var border1 = new RoundCornerView {
				BackgroundColor = Color.Red,
				CornerRadius = 4,
			};

			var border2 = new RoundCornerView {
				BackgroundColor = Color.Blue,
				CornerRadius = 14,
			};

			var border3 = new RoundCornerView {
				BackgroundColor = Color.Green,
				CornerRadius = 12,
			};

			var border4 = new RoundCornerView {
				BackgroundColor = Color.Yellow,
				CornerRadius = 42,
			};

			layout.Children.Add (border1, () => new Rectangle (10, 10, (layout.Width / 2) - 20, (layout.Height / 2) - 20));
			layout.Children.Add (border2, () => new Rectangle ((layout.Width / 2) + 10, 10, (layout.Width / 2) - 20, (layout.Height / 2) - 20));
			layout.Children.Add (border3, () => new Rectangle (10, (layout.Height / 2) + 10, (layout.Width / 2) - 20, (layout.Height / 2) - 20));
			layout.Children.Add (border4, () => new Rectangle ((layout.Width / 2) + 10, (layout.Height / 2) + 10, (layout.Width / 2) - 20, (layout.Height / 2) - 20));

			Content = layout;
		}
        /// <summary>
        /// Updates the element.
        /// </summary>
        /// <param name="element">Element.</param>
        private void UpdateElement(RoundCornerView element)
        {
            var colorConverter = new ColorConverter();

            Border.Background      = (Brush)colorConverter.Convert(element.BackgroundColor, null, null, null);
            Border.BorderBrush     = (Brush)colorConverter.Convert(element.BorderColor, null, null, null);
            Border.BorderThickness = new System.Windows.Thickness(element.BorderWidth);
            Border.CornerRadius    = new CornerRadius(element.CornerRadius);
        }
        /// <summary>
        /// Updates the element.
        /// </summary>
        /// <param name="element">Element.</param>
        private void UpdateElement(RoundCornerView element)
        {
            if (element.BackgroundColor == Xamarin.Forms.Color.Transparent)
            {
                BackgroundColor = UIKit.UIColor.Clear;
            }
            else
            {
                BackgroundColor = element.BackgroundColor.ToUIColor();
            }

            Layer.CornerRadius = element.CornerRadius;
            Layer.BorderColor  = element.BorderColor.ToUIColor().CGColor;
            Layer.BorderWidth  = (nfloat)element.BorderWidth;
        }
        protected override void OnAppearing()
        {
            base.OnAppearing();

            var layout = new RelativeLayout();

            var border1 = new RoundCornerView {
                BackgroundColor = Color.Red,
                CornerRadius    = 34,
                BorderColor     = Color.Yellow,
                BorderWidth     = 18,
            };

            var border2 = new RoundCornerView {
                BackgroundColor = Color.Blue,
                CornerRadius    = 14,
            };

            var border3 = new RoundCornerView {
                BackgroundColor = Color.Green,
                CornerRadius    = 12,
                BorderColor     = Color.Red,
                BorderWidth     = 4,
            };

            var border4 = new RoundCornerView {
                BackgroundColor = Color.Yellow,
                CornerRadius    = 42,
            };

            var shape = new BoxView {
                BackgroundColor = Color.Aqua
            };
            var shapeLayout = new RelativeLayout();

            shapeLayout.Children.Add(shape, () => new Rectangle(-50, -30, 100, 100));
            border1.Content = shapeLayout;

            layout.Children.Add(border1, () => new Rectangle(10, 10, (layout.Width / 2) - 20, (layout.Height / 2) - 20));
            layout.Children.Add(border2, () => new Rectangle((layout.Width / 2) + 10, 10, (layout.Width / 2) - 20, (layout.Height / 2) - 20));
            layout.Children.Add(border3, () => new Rectangle(10, (layout.Height / 2) + 10, (layout.Width / 2) - 20, (layout.Height / 2) - 20));
            layout.Children.Add(border4, () => new Rectangle((layout.Width / 2) + 10, (layout.Height / 2) + 10, (layout.Width / 2) - 20, (layout.Height / 2) - 20));

            Content = layout;
        }
		protected override void OnAppearing ()
		{
			base.OnAppearing ();
		
			var layout = new RelativeLayout ();

			var border1 = new RoundCornerView {
				BackgroundColor = Color.Red,
				CornerRadius = 34,
                BorderColor = Color.Yellow,
                BorderWidth = 18,
            };

			var border2 = new RoundCornerView {
				BackgroundColor = Color.Blue,
				CornerRadius = 14,
			};

            var border3 = new RoundCornerView {
				BackgroundColor = Color.Green,
				CornerRadius = 12,
                BorderColor = Color.Red,
                BorderWidth = 4,                
			};

			var border4 = new RoundCornerView {
				BackgroundColor = Color.Yellow,
				CornerRadius = 42,
			};

            var shape = new BoxView { BackgroundColor = Color.Aqua };
            var shapeLayout = new RelativeLayout();
            shapeLayout.Children.Add(shape, () => new Rectangle(-50, -30, 100, 100));
            border1.Content = shapeLayout;

            layout.Children.Add (border1, () => new Rectangle (10, 10, (layout.Width / 2) - 20, (layout.Height / 2) - 20));
			layout.Children.Add (border2, () => new Rectangle ((layout.Width / 2) + 10, 10, (layout.Width / 2) - 20, (layout.Height / 2) - 20));
			layout.Children.Add (border3, () => new Rectangle (10, (layout.Height / 2) + 10, (layout.Width / 2) - 20, (layout.Height / 2) - 20));
			layout.Children.Add (border4, () => new Rectangle ((layout.Width / 2) + 10, (layout.Height / 2) + 10, (layout.Width / 2) - 20, (layout.Height / 2) - 20));

			Content = layout;
		}