xcode ios如何对ui元素进行分组

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11229247/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 00:42:20  来源:igfitidea点击:

how to group ui elements ios

objective-ciosxcode

提问by thommie

I'm looking for a way to group some ui elements together just like the twitter app does but I can't find anything which suits my needs.

我正在寻找一种方法来将一些 ui 元素组合在一起,就像 twitter 应用程序所做的那样,但我找不到任何适合我需要的东西。

equivalent to jpanel in java or groupbox in .net

相当于java中的jpanel或.net中的groupbox

this is what I'm talking about: http://i46.tinypic.com/169etxi.jpg

这就是我所说的:http: //i46.tinypic.com/169etxi.jpg

采纳答案by thommie

One, not so neat, solution is to create an image and use it as the background and put the ui elements on top of it. Here is the image I used(retina). http://tinypic.com/r/6i9m3b/6

一个,不是那么简洁,解决方案是创建一个图像并将其用作背景并将 ui 元素放在它上面。这是我使用的图像(视网膜)。 http://tinypic.com/r/6i9m3b/6

回答by Bruno Koga

On interface builder, you can embed ui elements in a view or scrollview. Just select all the elements you want to group and then click Editor -> Embed In -> View/Scrollview

在界面构建器上,您可以在视图或滚动视图中嵌入 ui 元素。只需选择要分组的所有元素,然后单击 Editor -> Embed In -> View/Scrollview

回答by logancautrell

Grouping UI elements in UIKit is as simple as putting child views into a parent UIView. Just use the addSubview:method.

在 UIKit 中对 UI 元素进行分组就像将子视图放入父视图一样简单UIView。就用这个addSubview:方法吧。

From the docs:

从文档:

Views can embed other views and create sophisticated visual hierarchies. This creates a parent-child relationship between the view being embedded (known as the subview) and the parent view doing the embedding (known as the superview).

视图可以嵌入其他视图并创建复杂的视觉层次结构。这在被嵌入的视图(称为子视图)和执行嵌入的父视图(称为超级视图)之间创建了父子关系。

Here are the docs:

以下是文档:

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView/UIView.html

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIView_Class/UIView/UIView.html