Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change height of NSSegmentedControl

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?

like image 202
Cory Avatar asked Aug 13 '14 15:08

Cory


1 Answers

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.

like image 122
Ky. Avatar answered Oct 11 '22 13:10

Ky.