When writing Cocoa applications, I do most of the layout of the user interface programmatically. For instance:
NSRect popUpFrame = NSMakeRect(10, 10, 100, kDefaultPopUpButtonHeight); NSPopUpButton * popUp = [[NSPopUpButton alloc] initWithFrame:popUpFrame];
My question is about kDefaultPopUpButtonHeight constant. I currently maintain a source file full of such constants, and I manually fill in the required sizes. I can determine the correct sizes by dropping the new control into an empty view in Interface Builder, and then checking its properties to see what size IB gives it.
There must be a better way. Is it possible to access these values ββat runtime? Ideally, I would expect that each NSControl should have a class method something like this: +(NSSize)defaultSize or for controls like NSButton , which have different default sizes depending on the particular button style, something like +(NSSize)defaultSizeForButtonStyle:(NSButtonStyle)buttonStyle .
The Apple Human Interface Guidelines contain information about the layout of the controls and the distance between the controls, but it doesn't say anything about the correct sizes for the individual controls.
source share