如何使用 AVCaptureSession 实现像苹果一样的相机应用程序?

How to implement apple like camera app using AVCaptureSession?

In the iOS(9) camera app the controls overlay does not rotate but when 'Record' is selected the video is outputted with the correct orientation.有没有人知道苹果是如何实现这个的。

您有几个不同的选项来实现相同的效果:

您可以旋转相机,但保持 UI 不变,当设备本身旋转时它匹配 UIDevice.currentDevice().orientation

您可以在拍摄时存储设备方向,然后旋转视频。

您甚至可以设置捕获会话的捕获连接以匹配设备方向,同时保持预览连接相同。 Check this out for a similar question

我使用 2 个不同的 UIWindow 实例实现了您正在寻找的内容,一个用于视频预览层,一个用于 UI 显示在它。 UIWindow 和 UI 需要透明背景才能使预览层保持可见。