MobileEditorRenderer.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using InABox.Mobile;
  2. using InABox.Mobile.iOS;
  3. using UIKit;
  4. using Xamarin.Forms;
  5. using Xamarin.Forms.Platform.iOS;
  6. [assembly: ExportRenderer(typeof(MobileEditor), typeof(MobileEditorRenderer))]
  7. namespace InABox.Mobile.iOS
  8. {
  9. class MobileEditorRenderer : EditorRenderer
  10. {
  11. public MobileEditorRenderer()
  12. {
  13. UIKeyboard.Notifications.ObserveWillShow((sender, args) =>
  14. {
  15. if (Element != null)
  16. {
  17. Element.Margin = new Thickness(0, 0, 0, args.FrameEnd.Height); //push the entry up to keyboard height when keyboard is activated
  18. }
  19. });
  20. UIKeyboard.Notifications.ObserveWillHide((sender, args) =>
  21. {
  22. if (Element != null)
  23. {
  24. Element.Margin = new Thickness(0); //set the margins to zero when keyboard is dismissed
  25. }
  26. });
  27. }
  28. protected override void OnElementChanged(ElementChangedEventArgs<Editor> e)
  29. {
  30. base.OnElementChanged(e);
  31. if (Control != null)
  32. {
  33. Control.Layer.CornerRadius = 5;
  34. Control.TextColor = UIColor.Black;
  35. }
  36. }
  37. }
  38. }