jxd*_*ter 38 subview addsubview ios
大家.
我有一些标签,我在xib文件中绘制它们,并使用代码添加背景视图,但背景视图位于这些标签的前面,所以我无法看到它们.所以,我的问题是如何在这些标签下面添加背景视图.
先感谢您.
Pau*_*l.s 63
如果你是谷歌,UIView你最终会得到文档 - UIView类参考
然后你需要向下看方法列表,直到找到一些听起来大致符合你需要的东西,比如这两个:
- (void)insertSubview:(UIView *)view atIndex:(NSInteger)index
Run Code Online (Sandbox Code Playgroud)
和
- (void)insertSubview:(UIView *)view belowSubview:(UIView *)siblingSubview
Run Code Online (Sandbox Code Playgroud)
此时,您只需阅读方法行为的描述,并选择最容易为您的设计实现的方法.如果您在提出问题之前尝试自己找到答案,这对您自己的学习非常有益
sch*_*sch 42
您可以使用该方法 insertSubview:atIndex:
[self.view insertSubview:backgroundView atIndex:0];
Run Code Online (Sandbox Code Playgroud)
您可以在Swift 3中调用此方法
view.insertSubview(yourSubView, at: 0)
Run Code Online (Sandbox Code Playgroud)
要么
view.sendSubview(toBack: yourSubView)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
27473 次 |
| 最近记录: |