Guest User

Untitled

a guest
Apr 24th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. using EffectsExemplo.iOS.Effects;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Text;
  6. using UIKit;
  7. using Xamarin.Forms;
  8. using Xamarin.Forms.Platform.iOS;
  9.  
  10. [assembly: ResolutionGroupName("Bertuzzi")]
  11. [assembly: ExportEffect(typeof(FocusEffect), "FocusEffect")]
  12. namespace EffectsExemplo.iOS.Effects
  13. {
  14. public class FocusEffect : PlatformEffect
  15. {
  16. UIColor backgroundColor;
  17.  
  18. protected override void OnAttached()
  19. {
  20. try
  21. {
  22. Control.BackgroundColor = backgroundColor = UIColor.FromRGB(204, 153, 255);
  23. }
  24. catch (Exception ex)
  25. {
  26. Console.WriteLine("Error: ", ex.Message);
  27. }
  28. }
  29.  
  30. protected override void OnDetached()
  31. {
  32. }
  33.  
  34. protected override void OnElementPropertyChanged(PropertyChangedEventArgs args)
  35. {
  36. base.OnElementPropertyChanged(args);
  37.  
  38. try
  39. {
  40. if (args.PropertyName == "IsFocused")
  41. {
  42. if (Control.BackgroundColor == backgroundColor)
  43. {
  44. Control.BackgroundColor = UIColor.White;
  45. }
  46. else
  47. {
  48. Control.BackgroundColor = backgroundColor;
  49. }
  50. }
  51. }
  52. catch (Exception ex)
  53. {
  54. Console.WriteLine("Error: ", ex.Message);
  55. }
  56. }
  57. }
  58. }
Add Comment
Please, Sign In to add comment