我的 Storyboard中有一个带有多个 UIButton 的 View Controller 。其中之一激活子层中显示的 AVFoundation 相机预览层:
captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
captureVideoPreviewLayer.frame = self.view.bounds;
[self.view.layer addSublayer:captureVideoPreviewLayer];
除了预览层呈现在我的按钮之上之外,这工作正常,因此即使按钮仍然可点击,用户也看不到它们。有没有一种简单的方法可以将子层放置在按钮下方?或者在层中提升按钮的简单方法?非常感谢!
最佳答案
按钮层都是主视图层的子层。您需要将相机预览层放在按钮层的下方。试试这个:
// put it behind all other subviews
[self.view.layer insertSublayer:captureVideoPreviewLayer atIndex:0];
// or, put it underneath your buttons, as long as you know which one is the lowest subview
[self.view.layer insertSublayer:captureVideoPreviewLayer below:lowestButtonView.layer];
关于ios - CALayer - 将子层放在 Storyboard UIButtons 下方?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16043130/