ios UI控件之UILabel

 

上面的通过代码实现:

NSString *str = @"字符串大小字符串大小字符串大小字符串大小";
UIFont *font = [UIFont fontWithName:@"Arial" size:50.0f];
CGSize size = CGSizeMake(320, 2000);


UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
[label setNumberOfLines:0];


CGSize labelSize = [str sizeWithFont:font
constrainedToSize:size
lineBreakMode:UILineBreakModeWordWrap];


label.frame = CGRectMake(0, 0, labelSize.width, labelSize.height);
label.textColor = [UIColor blackColor];
label.font = font;
label.text = str;
[self.view addSubview:label];

下面的通过xib文件的拉控件实现

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-19
  • 2022-12-23
  • 2021-09-03
  • 2022-12-23
  • 2021-11-23
猜你喜欢
  • 2022-12-23
  • 2021-07-31
  • 2022-02-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-05-07
相关资源
相似解决方案