CGFloat w = self.view.frame.size.width;
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 400, w, 0)];
[label setBackgroundColor:[UIColor grayColor]];
[label setNumberOfLines:0];
NSString *str = @"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
label.text = str;
[label sizeToFit];
CGFloat h = label.frame.size.height;
CGFloat length = label.frame.size.width;
CGFloat y = 480 - h;
[label setFrame:CGRectMake(0, y, length, h)];
[self.view addSubview:label];
UILabel 自适应
时间: 2024-10-24 12:40:03