UISB Label

 

ViewController.m

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

//创建UI控件函数
-(void) createUI
{
    //定义并创建一个UILabel 对象
    //UILabel可以显示在屏幕上 并且显示文字的一种UI视图
    
    UILabel* label =[[UILabel alloc] init];
    //显示文字的赋值
    label.text = @"hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world hello world";
    //设定label显示位置
    label.frame= CGRectMake(100, 100, 160, 160);
    // 设置label背景颜色
    label.backgroundColor = [UIColor greenColor];
    // label 显示屏幕
    [self.view addSubview:label];
    //设置label文字大小
    label.font = [UIFont systemFontOfSize:20];
    
    //设置文字颜色
    label.textColor=[UIColor blueColor];
    
    //label 高级属性
    //设置阴影颜色
    label.shadowColor = [UIColor greenColor];
    //设置阴影的偏移位置
    label.shadowOffset=CGSizeMake(10, 10);
    
    // 设置text文字居中
    label.textAlignment=NSTextAlignmentCenter;
    
    // 设置 label文字显示的行数 默认值为1 只用来显示1行
    
    //0 按照尽可能多进行显示
    label.numberOfLines=0;
    
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //调用创建UI函数
    
    [self createUI];
    
}

 

posted @ 2020-09-07 21:11  逆欢  阅读(153)  评论(0编辑  收藏  举报