UI<05>

//声明UILabel对象
@property (nonatomic,strong) UILabel *label;
 // 初始化
    self.label = [[UILabel alloc] init];
    self.label.backgroundColor = [UIColor clearColor];
   
    //设置frame
    self.label.frame = CGRectMake((self.view.frame.size.width-80)/2.0,80, 80, 100);
   
    //设置文本内容
    self.label.text = @"In the evening one may praise the day.";
    //设置字体大小
    self.label.font = [UIFont systemFontOfSize:17.0];
    //设置字体颜色
    self.label.textColor = [UIColor blueColor];
    //设置阴影偏移量
    //self.label.shadowOffset = CGSizeMake(1.0, 0.5);
    //设置阴影颜色
    //self.label.shadowColor = [UIColor purpleColor];
    //设置文本对其方式
    self.label.textAlignment = NSTextAlignmentCenter;
    self.label.lineBreakMode = NSLineBreakByTruncatingMiddle;
    //设置行数 默认1 0代表自动换行
    //self.label.numberOfLines = 0;
   
    //设置自适应宽度
    //self.label.adjustsFontSizeToFitWidth = YES;
    //设置能否与用户交互
    self.label.userInteractionEnabled = YES;
    //设置文本是否可变
    self.label.enabled = YES;
    //设置文本是否高亮显示
    //self.label.highlighted = YES;
    //设置文本高亮显示颜色
    //self.label.highlightedTextColor = [UIColor redColor];
   

   
    [self.view addSubview:self.label];
   
 
原文地址:https://www.cnblogs.com/iQingYang/p/6687610.html