UI基礎 UILabel
阿新 • • 發佈:2020-07-14
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; }