NSSegmentedCellのサブクラスを作成し、次のようにdrawWithFrameを実装しました。
#import "CustomSegmentedCell.h"
@implementation CustomSegmentedCell
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
int i=0, count=[self segmentCount];
NSRect segmentFrame=cellFrame;
for(i=0; i<count; i++) {
segmentFrame.size.width=[self widthForSegment:i];
[NSGraphicsContext saveGraphicsState];
// Make sure that segment drawing is not allowed to spill out into other segments
NSBezierPath* clipPath = [NSBezierPath bezierPathWithRect: segmentFrame];
[clipPath addClip];
[self drawSegment:i inFrame:segmentFrame withView:controlView];
[NSGraphicsContext restoreGraphicsState];
segmentFrame.origin.x+=segmentFrame.size.width;
}
_lastDrawRect=cellFrame;
}
@end
問題は、アプリの最初の起動時にセグメントが描画されなかったことです。セグメント化されたコントロールが描画されるはずの空白の領域をマウスでクリックした場合にのみ表示されます。ここで欠落しているものを教えてください。
ありがとう、