0

Is it somehow possible to subclass NSTextField, and add a 6px border to the bottom side only? The other sides should be borderless. No shadows, no anything.

I tried replicating this with a NSView subclass 6px high instead (so 2 separate objects), but the view is drawing itself too much when I'm scrolling fast, there seems to be some kind of lag (though I do nothing more than NSRectFill([self bounds]).

That's why I want to subclass NSTextField instead.

  • Did you try nesting it? First add a UIView which is 6px higher than the UITextField. Then add the UITextField (at 0/0) as subview to it. Let the UIView have the same background colour as the UITextField has and it should look fine - even when scrolling fast. – Hermann Klecker Feb 23 '13 at 23:30

1 Answers1

2

NSTextField's drawing is actually done by an instance of NSTextFieldCell, so that's what you want to subclass, and the method you want to override is -drawInteriorWithFrame:inView:. Setting the cell class of a text field in a .xib file is a bit of a pain, but you can do it by looking through the view hierarchy, expanding the arrow next to the text field, and selecting the cell there, and then setting its custom class.

Siobhán
  • 1,451
  • 10
  • 9