UILabel之小白学习纪录篇
UILabel *newLabel = [[UILabel alloc] initWithFrame:CGRectMake(100, 300, width, height)];
[self.view addSubview:newLabel];
[newLabel setText:@"我被改变了"];
//或者
newLabel.text = @"我被改变了";
[newLabel setTextColor:[UIColor blackColor]];
[newLabel setFont:[UIFont systemFontOfSize:12]];
//居左NSTextAlignmentLeft\居中NSTextAlignmentCenter\居右NSTextAlignmentRight
[newLabel setTextAlignment:NSTextAlignmentCenter];]
[newLabel setShadowColor:[UIColor greenColor]];
[newLabel setShadowOffset:CGSizeMake(0,-2)];
- 设置行数(当文本需要自适应的时候,需将行数设为0)
newLabel.numberOfLines = 0;
newLabel.adjustFontSizeToFitWidth = YES;
newLabel.highlighted = YES;
newLabel.highlightedTextColor = [UIColor redColor];
nameLabel.userInteractionEnabled = YES;
nameLabel.enabled = NO;
网友评论