iOS Series Basics 06 tags and buttons (Label & button)
Directory:
- Label control
- Button controls
- Summary
The tabs and buttons are two common controls, and we'll learn each one.
1. Label controls
Create a project named "Labelandbuttonsimple" using the single View application template
(PS: The specific creation process and the introduction of various settings, etc. can be seen in the previous article, here is simple:)
(1) Open Xcode and select Create a new Xcode Project:
(2) Select the single View application template and click Next:
(3) To set up information about the project, click Next to save and complete the creation:
(4) Open the Main.storyboard file, drag a Label control from the object library, and place it in the center of the Design view:
As you can see, the label tag's property inspector includes a label and a view two groupings:
- A label group is primarily about setting text-related properties, such as text content, font color, font type, alignment, and so on.
- The view group primarily sets controls from the view angle, such as the background, appearance, and so on.
All views have a view group.
The previous article describes that we can implement the text input of a label control by double-clicking or setting properties, where the property refers to the Text property under the label group.
Of course, you can also use code to manipulate this property of a Label control, enabling text to be set up and edited.
It is important to note that the object library includes controllers, basic controls, advanced controls, and gestures.
With the upgrade of the version, the object library is constantly expanding and perfecting, it may not be possible to find the specified control in a short time, we can enter the control name directly in the object library, or use the search bar under the object library to find it.
2. Button controls
With the label control above, drag a button control from the object library and place it directly below the label label.
Double-click the button to enter the text OK:
Now that the button is in the default state (the normal display state is not clicked), let's run a look at the effect:
In order to be beautiful, it is generally necessary to optimize the button through the property inspector.
Open the Property inspector and locate the type setting:
Expand the Type drop-down list, you can select many button types,
Among them, the meanings are as follows:
- Custom: Customized type. This type can be used if we do not like the fillet button.
- System: Default property, which indicates that the button has no border. Before iOS 7, the button defaults to rounded rectangles.
- Detail Disclosure: Detail display button (a circle, inside a letter i), mainly used in the table view of the details of the display.
- Info Light and Info Dark: These are information buttons that, like the detail display buttons above, indicate that there is some information that needs to be displayed, or something that can be set.
- Add Contact: Adds a contacts button (a circle, inside a +).
If you want the button to be highlighted in the center when you click the button, you can tick the show Touch on Highlight checkbox in drawing.
In order to highlight the effect, we can set the button background to dark color, which can be set in the View-background of the property Inspector:
Here, I set the black, in order to observe the effect of the highlight. hehe, the result of the operation is as follows:
3. End
Here we do not have any code to click on the action event, but so far we have learned to create and set the label and button related properties.
It is also a small sense of accomplishment. Oh.
Next we'll learn how to add action events to them and make a small case. Come on??
iOS Series Basics 06 tags and buttons (Label & button)