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
Post a Comment