1、UILable:
#pragma mark 通过代码的方式创建UITextField
-(void)makeUILableWithSourceCode{
UILabel *lable=[[UILabel alloc]init];
lable.frame = CGRectMake(0, 0, 200, 30);
CGFloat centerX = self.view.frame.size.width*0.5;
CGFloat centerY = self.view.frame.size.height*0.5;
lable.center = CGPointMake(centerX, centerY);//通过设置center的方式将lable的位置有(0 , 0)调整到屏幕中间
lable.text = @"hello world";
lable.textColor = [UIColor blueColor];
[lable setBackgroundColor:[UIColor yellowColor]];
[lable setTextAlignment:NSTextAlignmentCenter]; //设置文字在lable的位置为居中对齐
[self.view addSubview:lable];
}
#pragma mark 通过代码的方式创建UITextField
-(void)makeUILableWithSourceCode{
UILabel *lable=[[UILabel alloc]init];
lable.frame = CGRectMake(0, 0, 200, 30);
CGFloat centerX = self.view.frame.size.width*0.5;
CGFloat centerY = self.view.frame.size.height*0.5;
lable.center = CGPointMake(centerX, centerY);//通过设置center的方式将lable的位置有(0 , 0)调整到屏幕中间
lable.text = @"hello world";
lable.textColor = [UIColor blueColor];
[lable setBackgroundColor:[UIColor yellowColor]];
[lable setTextAlignment:NSTextAlignmentCenter]; //设置文字在lable的位置为居中对齐
[self.view addSubview:lable];
}