xcode4.3 - Cocoa: How to dynamically size the NSTextField? -


i created label:

nstextfield *label = [nstextfield alloc] initwithframe:nsmakerect(50, 50, 100, 50)];     [txtfield setstringvalue:inputstring];     [txtfield seteditable:false]; 

the length of inputstring unknown @ compile time, how can resize label fits in 1 line , center after giving inputstring?

i'm still new cocoa, help!

use nscontrol's "- (void)sizetofit" method. resize textfield according text in it.

to make text centered, can in interface builder , settings not change update size of textfield using sizetofit.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -