foreword
Recently, I started to learn about UI for iOS development. The learning process started from ULable. The author wrote notes step by step to record his learning process.
1. The concept of UILable
Our UILable is aA view that can be displayed on the screen and can display text, the text on our qq or the circle of friends on wechat are actually a kind of UILabel
2. The properties of UILable
Our UILable, like any of our objects, needs to be created through alloc and init
Attribute 1: text
The text property of UILabel is a string object, so we must also assign a string object when assigning a value
Attribute 2: frame
Frame means frame
Because the parent class of our UILable is our UIView, all UIViews including UIView subclasses have this property
Attribute 3: backgroundColor
Through the code, we can see that the background color we can set is not only our lable object, but also the background color of our original interface
Attribute 4: font
We can also set our font size
Attribute 5: textColor
advanced properties
It is more important to note here that ournumberOfLinesAttribute, we generally set it to 0 to automatically adjust the number of lines of our text.
At the same time, we use textAlignment to set the alignment position of our text box. Alignment means alignment
We must pay attention here that we must add the subview we created to our parent view, otherwise the view we created will not be displayed
Finally, it must be noted that we need to call the function we created in our viewDidLoad method to display our view, otherwise it cannot be displayed
Here is our final rendering