[英]how to add uiview as a subview to existing view
I want to add a UIView
of smaller frame as subview to parental view but I am not getting the needed. 我想将较小框架的UIView
作为子视图添加到父母视图,但我没有得到所需。
UIView *view = [[UIView alloc] initWithFrame:something];
[self.view addSubview:view];
Can anyone suggest me the answer? 谁能给我建议答案?
Here you are adding a blank view to another view. 在这里,您要将空白视图添加到另一个视图。 Maybe you don't see it because it is blank? 也许您看不到它,因为它是空白的?
What is "something"? 什么是“东西”?
Have you tried - (void)bringSubviewToFront:(UIView *)view
? 您是否尝试过- (void)bringSubviewToFront:(UIView *)view
? It might be that you're adding this subview somewhere in the view hierarchy where it's obscured. 可能是您将此子视图添加到视图层次结构中被遮盖的位置。 In your code fragment there, you would add: 在您的代码片段中,您将添加:
[self.view bringSubviewToFront:view];
Of course, without supplying more code (preferably directly from your project, and which actually compiles), I'm just guessing. 当然,我只是在猜测,而无需提供更多代码(最好直接从您的项目中获取,并且实际上可以编译)。 What were you expecting to happen? 您期望发生什么? What actually happened? 实际发生了什么?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.