UI基础 UILabel

 

UILabel  m

 

#import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // UILable 标签 显示一段文字
    UILabel* label = [[UILabel alloc]initWithFrame:CGRectMake(10, 100, 150, 150)];
    //给标签添加一个背景色
    label.backgroundColor=[UIColor greenColor];
    //把标签添加到页面上
    [self.view addSubview:label];
//   label.alpha=0.1;
    
    label.text=@"这是一段话hahhahhahhahaa";
    //居中
    label.textAlignment=NSTextAlignmentCenter;
    
    //文字的颜色
    label.textColor=[UIColor redColor];
    
    //文字的大小
    label.font = [UIFont systemFontOfSize:30];
    //文字的大小 加粗
    label.font=[UIFont boldSystemFontOfSize:30];
    //填写字体的名称
//    label.font=[UIFont fontWithName:<#(nonnull NSString *)#> size:<#(CGFloat)#>]
    //阴影颜色
    label.shadowColor=[UIColor yellowColor];
    label.shadowOffset=CGSizeMake(10, 10);
    //设置行数
    label.numberOfLines=4;
    //圆角
    label.layer.cornerRadius=5;
    label.layer.masksToBounds=YES;
    
    //设置圆  cornerRadius 为 长/宽 的一半
    UILabel* label1=[[UILabel alloc]initWithFrame:CGRectMake(200, 200, 150, 150)];
    label1.backgroundColor=[UIColor redColor];
    [self.view addSubview:label1];
    label1.layer.cornerRadius=75;
    label1.layer.masksToBounds=YES;
    
    
    
}

 

posted @ 2020-07-13 22:54  逆欢  阅读(214)  评论(0编辑  收藏  举报