The Tale of Two Subclasses
Ben stock
Prologue
I am going to create a really beautiful set of controls that automatically change the appearance depending on the type of window in which they are used (for example, if you drop the button in a regular window, it looks like any other standard Aqua button. If you put it on NSPanelwith mask window NSHUDWindowMask, it will automatically switch your style to look good on the HUD. Until now, I subclass NSButton, NSTextField, NSSliderand NSSearchField. Last night I started with NSTabView, only to slam because of its lack of customization. it's a real pain in the ass Itza, but I'm a developer, so I'm used to look for their own way. The first thing I think to do is to add an instance NSSegmentedControlinstead of private tabs usedNSTabView. So far so good. I have buttons that can be selected, they are automatically updated when new ones are added NSTabViewItem, and they work just like the real thing.
And the pain begins ...
Finally, I start styling my segments, and ... WTF, I got into it, I just had to do acting or something else. Objective-C development slowly takes years of my life. No matter what I do, the “tracking areas” used NSSegmentedCelldo not seem to update when my segment width changes. Therefore, when my width changes, my work also. However, the actual tracking area is not updated (even when I redefine -updateTrackingAreas). It is very difficult to explain, so I decided to draw the rectangles of the segments behind and in front of those that were drawn superin -drawSegment:inFrame:withView. Here's a screenshot of my drawing drawn on top of the main tracking areas:

And here's the superimplementation above my rects segments:

, . , ( ):
-cellSize (NSSegmentedCell)-cellSizeForBounds: (NSSegmentedCell)-sizeToFit (NSSegmentedControl)-intrinsicContentSize (NSSegmentedControl)-setWidth:forSegment: (NSSegmentedControl/Cell)-startTrackingAt:inView: (NSSegmentedCell)-continueTracking:at:inView: (NSSegmentedCell)-stopTracking:at:inView:mouseIsUp: (NSSegmentedCell)
, - . , , , , , , , . Apple , , . , . , Auto Layout ( , - ), . , - , . !
P.S. , , , .; -)