object-c IOS ----UILable

创建一个  UILable对象

//创建一个UILable对象
    UILabel * label = [[UILabel alloc] init];
    label.text =@"hello world"; //label的文字
    label.frame= CGRectMake(100,100,160,40);//label的位置
    label.backgroundColor= [UIColor redColor];//label的背景颜色
    [self.view addSubview:label];//将label加到视图上
    label.font = [UIFont systemFontOfSize:12]; //设置文字大小
    label.textColor = [UIColor blueColor];//设置字体颜色
    label.shadowColor=  [UIColor grayColor]; //设置阴影颜色
    label.shadowOffset = CGSizeMake(3, 3) ;//设置阴影偏移位置
    label.textAlignment= NSTextAlignmentCenter;//设置对齐格式
    label.numberOfLines= 0;//label文字的行数 可换行 可设置 为 0 |  |22

猜你喜欢

转载自blog.csdn.net/weixin_41069726/article/details/88818555