📜  iOS-UI元素

📅  最后修改于: 2020-12-08 06:19:15             🧑  作者: Mango


什么是UI元素?

UI元素是我们可以在应用程序中看到的视觉元素。这些元素中的一些响应用户交互,例如按钮,文本字段,而其他则提供信息,例如图像,标签。

如何添加UI元素?

我们可以在代码中以及在界面生成器的帮助下添加UI元素。根据需要,我们可以使用其中之一。

我们的重点

我们将集中精力在通过应用程序中的代码添加UI元素上。使用界面生成器非常简单明了,我们只需要拖放UI元素即可。

我们的方法

我们将创建一个简单的iOS应用程序,并将其用于解释一些UI元素。

步骤1-创建一个基于View的应用程序,就像在我们的第一个iOS应用程序中一样。

步骤2-我们将仅更新ViewController.h和ViewController.m文件。

步骤3-然后我们在ViewController.m文件中添加一个专门用于创建UI元素的方法。

步骤4-我们将在我们的viewDidLoad方法中调用此方法。

步骤5-代码中的重要行已在代码中进行了解释,并在这些行上方添加了一行注释。

UI元素列表

UI特定元素及其相关功能在下面说明-

Sr.No. UI Specific Elements
1 Text Fields

It is an UI element that enables the app to get user input.

2 Input types – TextFields

We can set the type of input that user can give by using the keyboard property of UITextField.

3 Buttons

It is used for handling user actions.

4 Label

It is used for displaying static content.

5 Toolbar

It is used if we want to manipulate something based on our current view.

6 Status Bar

It displays the key information of device.

7 Navigation Bar

It contains the navigation buttons of a navigation controller, which is a stack of view controllers which can be pushed and popped.

8 Tab bar

It is generally used to switch between various subtasks, views or models within the same view.

9 Image View

It is used to display a simple image or sequence of images.

10 Scroll View

It is used to display content that is more than the area of screen.

11 Table View

It is used for displaying scrollable list of data in multiple rows and sections.

12 Split View

It is used for displaying two panes with master pane controlling the information on detail pane.

13 Text View

It is used for diplaying scrollable list of text information that is optionally editable.

14 View Transition

It explains the various view transitions between views.

15 Pickers

It is used for displaying for selecting a specific data from a list.

16 Switches

It is used as disable and enable for actions.

17 Sliders

It is used to allow users to make adjustments to a value or process throughout a range of allowed values.

18 Alerts

It is used to give important information to users.

19 Icons

It is an image representation used for an action or depict something related to the application.