CustomFrameRenderer.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Drawing;
  4. using System.Text;
  5. using CoreGraphics;
  6. using UIKit;
  7. using Xamarin.Forms;
  8. using Xamarin.Forms.Platform.iOS;
  9. using XamarinFormsGoogleDriveAPI.iOS.Renderer;
  10. [assembly: ExportRenderer(typeof(Frame), typeof(CustomFrameRenderer))]
  11. namespace XamarinFormsGoogleDriveAPI.iOS.Renderer
  12. {
  13. public class CustomFrameRenderer : FrameRenderer
  14. {
  15. public override void Draw(CGRect rect)
  16. {
  17. SetupShadowLayer();
  18. base.Draw(rect);
  19. }
  20. void SetupShadowLayer()
  21. {
  22. Layer.CornerRadius = 1; // 5 Default
  23. if (Element.BackgroundColor == Xamarin.Forms.Color.Default)
  24. {
  25. Layer.BackgroundColor = UIColor.White.CGColor;
  26. }
  27. else
  28. {
  29. Layer.BackgroundColor = Element.BackgroundColor.ToCGColor();
  30. }
  31. //Layer.ShadowRadius = 1;
  32. //Layer.ShadowColor = UIColor.Black.CGColor;
  33. //Layer.ShadowOpacity = 0.4f;
  34. //Layer.ShadowOffset = new CGSize(0f, 2.5f);
  35. Layer.RasterizationScale = UIScreen.MainScreen.Scale;
  36. Layer.ShouldRasterize = true;
  37. }
  38. }
  39. }