可能重复:
text size in label
感谢您的快速反馈 但那对我不起作用我在表格中使用标签..
UILabel *label1 = (UILabel *) [cell viewWithTag:1];
label1.backgroundColor = [UIColor clearColor];
label1.text=aStation.station_name;
label1.textColor = [UIColor colorWithRed:0.76 green:0.21 blue:0.07 alpha:1.0];
[label1 setFont:[UIFont fontWithName:@"Trebuchet MS" size:15]];
对于这种类型的标签我想限制字符数。 希望我会得到答案..
答案 0 :(得分:0)
NSString *myString = [self getStringValue]; // Set the value any way you like.
int maxLen = 10; // Or whatever your true maximum length is.
label.text = myString;
if (([myString length] > maxLen) label.text = [myString substringToIndex:maxLen];