0

editing (Editing) not editing(Not Editing)

I have Subclass NSTextFieldCell and then override this method:

-(void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
    NSRect customRect = cellFrame;
    customRect.origin.y = cellFrame.size.height - 1;
    customRect.origin.x = 0;
    NSColor *color = [NSColor grayColor];
    [color setFill];
    NSBezierPath *path = [NSBezierPath bezierPathWithRect:customRect];
    [path fill];
    [super drawWithFrame:customRect inView:controlView];
}

At last I Set Class field of NSTextFieldCell in Interface Builder

l'L'l
  • 44,951
  • 10
  • 95
  • 146
  • There are two Screenshots editing and not editing above my question.This is my fist time to ask for help.I 'm not very familiar with how to ask for help here. – gao yang Jul 19 '16 at 08:38

1 Answers1

0

It's not clear what you're trying to do exactly, although your NSTextFieldCell is only showing the very top of it (1 pixel high to be exact).

customRect.origin.y = cellFrame.size.height - 22;

If you want to see the cell when you're not editing it then move it up (change 1 to 22, etc).

l'L'l
  • 44,951
  • 10
  • 95
  • 146
  • Thanks a lot,I just want to make my TextField only show it's bottom border like QQ's. I only found this way on internet. Is there a better way? – gao yang Jul 19 '16 at 11:11