CALayer - 将故障板放在故事板UIButtons下面? [英] CALayer - Place sublayer below storyboard UIButtons?

查看:115
本文介绍了CALayer - 将故障板放在故事板UIButtons下面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的故事板里有一个带有几个UIButton的视图控制器。其中一个激活子图层中显示的AVFoundation相机预览图层:

I've got a view controller in my storyboard with several UIButtons. One of them activates an AVFoundation camera preview layer shown in a sublayer:

captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
captureVideoPreviewLayer.frame = self.view.bounds;
[self.view.layer addSublayer:captureVideoPreviewLayer];

除了预览图层渲染在我的按钮顶部之外,这是正常的,所以即使按钮仍然是可点击的,用户无法看到它们。有没有一种简单的方法将子图层放在按钮下面?或者在图层中提升按钮的简单方法?非常感谢!

This works correctly except for the fact that the preview layer is rendered on top of my buttons so even though the buttons are still clickable they are not able to be seen by the user. Is there an easy way to place the sublayer below the buttons? Or an easy way to raise the buttons up in the layer? Thank you much!

推荐答案

按钮图层是主视图图层的所有子图层。您需要将相机预览图层放在按钮的图层下方。试试这个:

The button layers are all sublayers of the main view's layers. You'll need to put your camera preview layer below the button's layers. Try this:

// 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];

这篇关于CALayer - 将故障板放在故事板UIButtons下面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆