I would like to draw my own TextField with 3 pictures.
- input_l.png - left side of the input
- input_m.png - middle part of the input - 1px wide - supposed to stretch or multiply to fill middle part
- input_r.png - right side
All images contain border, background, shadows, just everything i need to draw it only with those pictures.
But I cannot manage to draw it with subclass of NSTextField and these methods:
- (void)awakeFromNib
{
[self setDrawsBackground:NO];
}
- (void)drawRect:(NSRect)rect
{
NSDrawThreePartImage(rect, [NSImage imageNamed:@"input_l.png"], [NSImage imageNamed:@"input_m.png"], [NSImage imageNamed:@"input_r.png"], NO, NSCompositeSourceOut, 1.0, NO);
[super drawRect:rect];
}
It draws black background with text/placeholder.
This is how it is supposed to look: http://d.pr/i/VLEN
If there are any other way, better, to draw this please tell me :) It just occured to me that I could use 1px wide background image without borders to draw this and in code make corners rounded and somehow draw even border. However I still would like to know how to do it the way I tried, for future use.