SHARE
TWEET

Untitled

a guest Jun 15th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [assembly: ExportRenderer(typeof(GradientLabel), typeof(GradientLabelRenderer))]
  2.  
  3. namespace YourNamespace.Droid.Renderers
  4. {
  5.     public class GradientLabelRenderer : LabelRenderer
  6.     {
  7.         public GradientLabelRenderer(Context context): base(context)
  8.         {
  9.         }
  10.  
  11.         protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
  12.         {
  13.             base.OnElementChanged(e);
  14.             SetColors();
  15.         }
  16.  
  17.         protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
  18.         {
  19.             base.OnElementPropertyChanged(sender, e);
  20.             SetColors();
  21.         }
  22.  
  23.         private void SetColors()
  24.         {
  25.             var c1 = (Element as GradientLabel).TextColor1.ToAndroid();
  26.             var c2 = (Element as GradientLabel).TextColor2.ToAndroid();
  27.  
  28.             Shader myShader = new LinearGradient(
  29.                 0, 0, Control.MeasuredWidth, 0,
  30.                 c1, c2,
  31.                 Shader.TileMode.Clamp);
  32.  
  33.             Control.Paint.SetShader(myShader);
  34.             Control.Invalidate();
  35.         }
  36.     }
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top