Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion ZXing.Net.MAUI/Apple/CameraManager.ios.maccatalyst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using UIKit;
using Microsoft.Maui;
using MSize = Microsoft.Maui.Graphics.Size;
using CoreAnimation;

namespace ZXing.Net.Maui
{
Expand Down Expand Up @@ -254,8 +255,26 @@ public PreviewView(AVCaptureVideoPreviewLayer layer) : base()
public override void LayoutSubviews()
{
base.LayoutSubviews();
CATransform3D transform = CATransform3D.MakeRotation(0, 0, 0, 1.0f);
switch (UIDevice.CurrentDevice.Orientation)
{
case UIDeviceOrientation.Portrait:
transform = CATransform3D.MakeRotation(0, 0, 0, 1.0f);
break;
case UIDeviceOrientation.PortraitUpsideDown:
transform = CATransform3D.MakeRotation((nfloat)Math.PI, 0, 0, 1.0f);
break;
case UIDeviceOrientation.LandscapeLeft:
transform = CATransform3D.MakeRotation((nfloat)(-Math.PI / 2), 0, 0, 1.0f);
break;
case UIDeviceOrientation.LandscapeRight:
transform = CATransform3D.MakeRotation((nfloat)Math.PI / 2, 0, 0, 1.0f);
break;
}

PreviewLayer.Transform = transform;
PreviewLayer.Frame = Layer.Bounds;
}
}
}
}
#endif