我的 iPhone 应用程序中有一个 UILabel。我想在一行中显示 UILabel 中的大句子。这意味着我想减小字体大小并在可见区域显示全文。我不想在多行中显示它。谁能帮我做到这一点?
我的代码是:
textViewLabel = [[UILabel alloc] initWithFrame:CGRectMake(8, 5, 194, 20)];
textViewLabel.text = @"I have an UILabel in my iPhone app. I have want";
textViewLabel.textColor = [UIColor lightGrayColor];
textViewLabel.font = [UIFont fontWithName:@"Helvetica" size:14];
textViewLabel.numberOfLines = 0;
textViewLabel.backgroundColor = [UIColor clearColor];
CGSize maximumLabelsize2 = CGSizeMake(194,20);
CGSize expectedLabelsize2 = [result sizeWithFont:textViewLabel.font constrainedToSize:maximumLabelsize2 lineBreakMode:textViewLabel.lineBreakMode];
CGRect messagesFrame = textViewLabel.frame;
messagesFrame.size.height = expectedLabelsize2.height;
textViewLabel.frame = messagesFrame;
任何人请帮我做到这一点?提前致谢。