void CreateUnToggleBackground() { nButton.BackgroundColor = UIColor.Clear; nButton.Layer.BorderColor = UIColor.Clear.CGColor; nButton.Layer.BorderWidth = 0; nButton.Layer.Sublayers = null; nButton.Layer.InsertSublayer(BackgroundExtension.CreateBackgroundGradientLayer((float)button.Height, (float)button.Width, button.CornerRadius, button.StartColor.ToUIColor(), button.EndColor.ToUIColor(), button.CenterColor.ToUIColor(), button.Angle.ToiOS()), 0); }
void CreateToggleBackground() { nButton.BackgroundColor = UIColor.Clear; nButton.Layer.BorderColor = UIColor.Clear.CGColor; nButton.Layer.BorderWidth = 0; nButton.Layer.Sublayers = null; nButton.Layer.InsertSublayer(BackgroundExtension.CreateBackgroundGradientLayer((float)button.Height, (float)button.Width, button.CornerRadius, button.ToggleStartColor.ToUIColor(), button.ToggleEndColor.ToUIColor(), button.ToggleCenterColor.ToUIColor(), button.Angle.ToiOS()), 0); if (button.Image != null && button.Image.File.Length > 0) { var background = BackgroundExtension.CreateBackgroundImage((float)button.Height, (float)button.Width, button.CornerRadius, button.Image.File); nButton.Layer.InsertSublayer(background, 1); } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName == "Width" || e.PropertyName == "Height") { Layer.BackgroundColor = UIColor.Clear.CGColor; Layer.BorderColor = UIColor.Clear.CGColor; Layer.BorderWidth = 0; Layer.InsertSublayer(BackgroundExtension.CreateBackgroundGradientLayer((float)frame.Height, (float)frame.Width, frame.CornerRadius, frame.StartColor.ToUIColor(), frame.EndColor.ToUIColor(), frame.CenterColor.ToUIColor(), frame.Angle.ToiOS()), 0); if (frame.Image != null && frame.Image.File.Length > 0) { var background = BackgroundExtension.CreateBackgroundImage((float)frame.Height, (float)frame.Width, frame.CornerRadius, frame.Image.File); Layer.InsertSublayer(background, 0); } } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName == nameof(button.Width) || e.PropertyName == nameof(button.Height)) { nButton.BackgroundColor = UIColor.Clear; nButton.Layer.BorderColor = UIColor.Clear.CGColor; nButton.Layer.BorderWidth = 0; nButton.Layer.InsertSublayer(BackgroundExtension.CreateBackgroundGradientLayer((float)button.Height, (float)button.Width, button.CornerRadius, button.StartColor.ToUIColor(), button.EndColor.ToUIColor(), button.CenterColor.ToUIColor(), button.Angle.ToiOS()), 0); if (button.Image != null && button.Image.File.Length > 0) { var background = BackgroundExtension.CreateBackgroundImage((float)button.Height, (float)button.Width, button.CornerRadius, button.Image.File); nButton.Layer.InsertSublayer(background, 1); } } }