Ok, here's my situation :
NSTextField
, set up as Multi-line Text LabelNSTextField
is supposed to be holding just ONE line of text (even if it's a multi-line one)NSTextField
has a fixed height.The issue :
NSTextField
's boundariesWhat I want :
NSTextField
's height accordingly.I know it may sound complicated, but I also know it CAN be done.
Any ideas? Any reference to point me to?
You can take the size of the string and then change the height accordingly
NSString *text = // your string
CGSize constraint = CGSizeMake(210, 20000.0f);
CGSize size = [text sizeWithFont:[UIFont fontWithName:@"Helvetica-Light" size:14] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
UITextField *cellTextLabel = [[UITextField alloc] initWithFrame:CGRectMake(70, 9, 230, size.height)];
cellTextLabel.lineBreakMode = UILineBreakModeWordWrap;
cellTextLabel.numberOfLines = 50;
cellTextLabel.backgroundColor = [UIColor clearColor];
cellTextLabel.text = text;
cellTextLabel.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:14];
[self.view addSubview:cellTextLabel];
[cellTextLabel release];