6

I'm trying to increase the height of a NSSegmentedControl, beyond the 25px "Regular" control size. I subclassed NSSegmentedCell, I understand that i have 2 methods to work with.

- (void)drawSegment:(NSInteger)segment
            inFrame:(NSRect)frame
           withView:(NSView *)controlView

- (void)drawWithFrame:(NSRect)frame
               inView:(NSView *)view

If I place a segmented control in IB then override the above methods in my NSSegmentedCell subclass. As excepted the frame and view that are passed in are based on the height of the segmented control in IB. So, Im not sure where to go from here.

Do I have to subclass NSSegmentedControl as well and draw my own control at my required height? and then use the NSSegmentedCell subclass to handle the segments?

Cory
  • 2,302
  • 20
  • 33
  • I am haven the same problem. How did you do it in the end? – Daniel Jun 06 '16 at 00:11
  • @Daniel, unfortunately, I never did find a solution for this, i ended up sticking with the default height. – Cory Jun 06 '16 at 18:36
  • I ended up doing my own SegmentedControl made out of NSButtons. It needs some cleanup and then I'll post on Github. It is basically a copy of what you can see in Pages or Keynote at the top of the sidebar when you select an image. – Daniel Jun 07 '16 at 04:35
  • Out of curiosity, why change the height? I'd like to see what the ideal outcome might look like – Ky - Aug 22 '18 at 02:54

1 Answers1

1

The default NSSegmentedControl does not allow you to adjust its drawn height. To do this, you will have to subclass it (and NSSegmentedCell) and override its drawing functions with your own.

Ky -
  • 30,724
  • 51
  • 192
  • 308
  • You can probably also do some nastiness with applying scaling transformations to the control's core animation layer, but I guarantee it won't look good – Ky - Aug 22 '18 at 02:52