当前位置:网站首页>[oc]- < getting started with UI> -- learning common controls
[oc]- < getting started with UI> -- learning common controls
2022-07-06 08:58:00 【About Xiaosi】
List of articles
UILabel
UI
UI It's the user interface
“UI Namely User Interface Written by , That's the user interface .UI Design is user interface design , The interface mainly includes mobile terminal (Android and IOS),PC End ,Dashboard.
UILabel What is it?
UILabel Is one that can be displayed on the screen , And can display text UI View
Create and use a UILabel
- We turn on Xcode choice App Development find ViewController stay Add and create the implementation part UILabel Function of

- Define to create a UILable object
- Display text assignment ,txt It's a string object
UILabel* label = [[UILabel alloc]init];
// Display text assignment ,txt It's a string object
label.text = @"Hello myiOSxxxxxxxxxx";
1)label Primary attribute
- Set up label Display position frame attribute
- CGRectMake(100, 300, 160, 200);
Note that the first two numbers represent the initial coordinate origin The following numbers represent the downward extension to the right And x y Distance of axis
// Set up label Display position
//100x- From the left ,100y From the upper left corner of the edge rectangle 160- wide 40- high
label.frame = CGRectMake(100, 300, 160, 200);
- Set the background color
label.backgroundColor = [UIColor grayColor];// There's a background color
label.backgroundColor = [UIColor clearColor]; // Transparent color
- This background color refers to the color of our text display , There will be text color behind
- Setting of the whole background color
Setting of the whole background color
self.view.backgroundColor = [UIColor whiteColor];
- take label Display on screen -
take label Display on screen
[self.view addSubview:label];
- Set up label Text size
- Set the text color
// Set up label Text size
//systemFontOfSize System default font size 12
label.font = [UIFont systemFontOfSize:24];
// Set the text color
label.textColor = [UIColor blackColor];
2)label Advanced properties
Set shadow color
Set the offset position of the shadow x- Lateral offset , y: Vertical offset downward distance
CGSizeMake(10, 10);Set text alignment –textAlignment
label Number of lines of text display , Default line
Others are greater than 0 Lines of text Try to show
If label.numberOfLines = 0,iOS Will automatically calculate the number of lines needed for text , Display as needed
// Set shadow color
label.shadowColor = [UIColor blueColor];
// Set the offset position of the shadow x- Lateral offset , y: Vertical offset downward distance
label.shadowOffset = CGSizeMake(10, 10);
// Set text alignment --textAlignment
// Default left alignment
label.textAlignment = NSTextAlignmentCenter ;
// Set up label Number of lines of text display , Default line
// Others are greater than 0 Lines of text Try to show
// If label.numberOfLines = 0,iOS Will automatically calculate the number of lines needed for text , Display as needed
label.numberOfLines = 0 ;
How to see the effect
open Xcode Select the virtual machine at the top

Use command+r function

This is our first UILabel Interface -- We make
label.numberOfLines = 0 ;
In this way, the system will automatically find the required position according to our purple potato
About a few colors
label.backgroundColor = [UIColor grayColor];// There's a background color
label.backgroundColor = [UIColor clearColor]; // Transparent color
When we write both of them, the system will default to transparent instead of gray , So we need to be transparent before writing Half of it is our own color
Setting of the whole background color
self.view.backgroundColor = [UIColor whiteColor]; The whole background window is white
Font and shadow colors
label.textColor = [UIColor blackColor];
label.shadowColor = [UIColor blueColor];
Pay attention to setting the shadow part Try not to overlap with the text
边栏推荐
- pytorch查看张量占用内存大小
- R language uses the principal function of psych package to perform principal component analysis on the specified data set. PCA performs data dimensionality reduction (input as correlation matrix), cus
- Navicat premium create MySQL create stored procedure
- LeetCode:剑指 Offer 04. 二维数组中的查找
- LeetCode:673. Number of longest increasing subsequences
- LeetCode:498. Diagonal traversal
- LeetCode:剑指 Offer 42. 连续子数组的最大和
- Marathon envs project environment configuration (strengthen learning and imitate reference actions)
- Intel distiller Toolkit - Quantitative implementation 1
- 如何有效地进行自动化测试?
猜你喜欢

UnsupportedOperationException异常

Advanced Computer Network Review(3)——BBR

Current situation and trend of character animation

如何正确截取字符串(例:应用报错信息截取入库操作)

Guangzhou will promote the construction of a child friendly city, and will explore the establishment of a safe area 200 meters around the school

CUDA implementation of self defined convolution attention operator
![[OC]-<UI入门>--常用控件-提示对话框 And 等待提示器(圈)](/img/af/a44c2845c254e4f48abde013344c2b.png)
[OC]-<UI入门>--常用控件-提示对话框 And 等待提示器(圈)

Tcp/ip protocol

Marathon envs project environment configuration (strengthen learning and imitate reference actions)

UML圖記憶技巧
随机推荐
Navicat premium create MySQL create stored procedure
LeetCode:39. 组合总和
[embedded] cortex m4f DSP Library
甘肃旅游产品预订增四倍:“绿马”走红,甘肃博物馆周边民宿一房难求
How to effectively conduct automated testing?
SimCLR:NLP中的对比学习
项目连接数据库遇到的问题及解决
LeetCode:41. 缺失的第一个正数
BN折叠及其量化
Improved deep embedded clustering with local structure preservation (Idec)
[OC]-<UI入门>--常用控件-提示对话框 And 等待提示器(圈)
LeetCode:剑指 Offer 48. 最长不含重复字符的子字符串
广州推进儿童友好城市建设,将探索学校周边200米设安全区域
Detailed explanation of dynamic planning
LeetCode:162. Looking for peak
Li Kou daily question 1 (2)
使用标签模板解决用户恶意输入的问题
[embedded] print log using JLINK RTT
不同的数据驱动代码执行相同的测试场景
超高效!Swagger-Yapi的秘密