点击它时如何将子视图带到前面? [英] How to bring a subview to the front when you tap it?

查看:67
本文介绍了点击它时如何将子视图带到前面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于它的大约30个子视图的视图。我想在子视图的viewcontroller中添加代码,这样当我点击子视图时,子视图会扩展以填充屏幕。

I have a view with about 30 subviews on it. I want to add code in my subview's viewcontroller so that when I tap the subview, the subview expands to fill the screen.

我正在使用 [self.view setFrame:rect] 展开子视图,这很好用。问题是其他29个子视图中的一些超出了我刚刚点击的子视图,因此它们仍然可见。

I'm using [self.view setFrame:rect] to expand the subview, and this works fine. The problem is that some of the other 29 subviews are above the subview that I just tapped, so they're still visible.

我尝试过使用来自父视图控制器的bringSubviewToFront ,但这似乎没有任何效果。是否有任何代码可以放在我的子视图的viewcontroller类中以实现这一点?

I've tried using bringSubviewToFront from the parent viewcontroller, but this appears to have no effect. Is there any code I can put in my subview's viewcontroller class to make this happen?

推荐答案

bringSubviewToFront应该可以工作,只需确保你'正确使用它。用法是。

bringSubviewToFront should work, just make sure you're using it correctly. The usage is.

[parentView bringSubviewToFront:childView];

这篇关于点击它时如何将子视图带到前面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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