diff --git a/Pixiview.iOS/Pixiview.iOS.csproj b/Pixiview.iOS/Pixiview.iOS.csproj index a297a95..a188d5a 100644 --- a/Pixiview.iOS/Pixiview.iOS.csproj +++ b/Pixiview.iOS/Pixiview.iOS.csproj @@ -70,6 +70,8 @@ + + diff --git a/Pixiview.iOS/Renderers/AdaptedPageRenderer.cs b/Pixiview.iOS/Renderers/AdaptedPageRenderer.cs index 248e127..c06fbd2 100644 --- a/Pixiview.iOS/Renderers/AdaptedPageRenderer.cs +++ b/Pixiview.iOS/Renderers/AdaptedPageRenderer.cs @@ -1,4 +1,5 @@ using System.Diagnostics.CodeAnalysis; +using Foundation; using Pixiview.iOS.Renderers; using Pixiview.UI; using Pixiview.Utils; @@ -11,6 +12,9 @@ namespace Pixiview.iOS.Renderers { public class AdaptedPageRenderer : PageRenderer { + UIDeviceOrientation lastOrientation; + NSObject observer; + public override void ViewDidLoad() { base.ViewDidLoad(); @@ -30,6 +34,20 @@ namespace Pixiview.iOS.Renderers { SetStatusBarStyle(style); } + + observer = UIDevice.Notifications.ObserveOrientationDidChange(ChangeOrientation); + ChangeOrientation(null, null); + } + + public override void ViewWillDisappear(bool animated) + { + if (observer != null) + { + observer.Dispose(); + observer = null; + } + + base.ViewWillDisappear(animated); } private void SetStatusBarStyle(UIStatusBarStyle style) @@ -64,5 +82,23 @@ namespace Pixiview.iOS.Renderers return UIStatusBarStyle.Default; } } + + void ChangeOrientation(object sender, NSNotificationEventArgs e) + { + var current = UIDevice.CurrentDevice.Orientation; + if (current == UIDeviceOrientation.FaceUp || current == UIDeviceOrientation.FaceDown) + { + //current = UIDeviceOrientation.Portrait; + return; + } + if (lastOrientation != current) + { + lastOrientation = current; + if (Element is AdaptedPage page) + { + page.OnOrientationChanged((Orientation)lastOrientation); + } + } + } } } diff --git a/Pixiview.iOS/Renderers/CircleImageRenderer.cs b/Pixiview.iOS/Renderers/CircleImageRenderer.cs new file mode 100644 index 0000000..85f77a2 --- /dev/null +++ b/Pixiview.iOS/Renderers/CircleImageRenderer.cs @@ -0,0 +1,31 @@ +using Pixiview.iOS.Renderers; +using Pixiview.UI; +using Xamarin.Forms; +using Xamarin.Forms.Platform.iOS; + +[assembly: ExportRenderer(typeof(CircleImage), typeof(CircleImageRenderer))] +namespace Pixiview.iOS.Renderers +{ + public class CircleImageRenderer : ImageRenderer + { + protected override void OnElementChanged(ElementChangedEventArgs e) + { + base.OnElementChanged(e); + + if (Control != null) + { + Control.Layer.MasksToBounds = true; + } + } + + public override void LayoutSubviews() + { + base.LayoutSubviews(); + + if (Control != null) + { + Control.Layer.CornerRadius = Control.Frame.Size.Width / 2; + } + } + } +} diff --git a/Pixiview.iOS/Renderers/RoundLabelRenderer.cs b/Pixiview.iOS/Renderers/RoundLabelRenderer.cs new file mode 100644 index 0000000..27f5fae --- /dev/null +++ b/Pixiview.iOS/Renderers/RoundLabelRenderer.cs @@ -0,0 +1,47 @@ +using System.ComponentModel; +using Pixiview.iOS.Renderers; +using Pixiview.UI; +using Xamarin.Forms; +using Xamarin.Forms.Platform.iOS; + +[assembly: ExportRenderer(typeof(RoundLabel), typeof(RoundLabelRenderer))] +namespace Pixiview.iOS.Renderers +{ + public class RoundLabelRenderer : LabelRenderer + { + protected override void OnElementChanged(ElementChangedEventArgs