I have a custom NSTextFieldCell
that i want to set on a NSTextField
.
If i set it on the IB it works fine.
And this gets it working like this:
But i want to set it programmatically and i try something like this:
-(void)awakeFromNib{
NSRect theRect = NSRectFromCGRect( NSMakeRect(50, 100, 100, 100));
NSTextField *inputField = [[NSTextField alloc] initWithFrame:theRect];
DRKHUDTextFieldCell *theC = [[DRKHUDTextFieldCell alloc] initTextCell:@"textfield"];
[inputField setCell:theC];
[[_window contentView] addSubview:inputField];
}
This is the result i get:
What is going wrong? Is my code bad or what?
Here is a working solution in swift. Above Objective C answer was not complete and hence didn't work for me.
You need to reset all the properties if you replace
cell
property. These are default values, try setting your own values matching your case.