UISegmentedControlに小さな色付きのインジケーター(色付きの長方形のみ)を追加したいと思います。UISegmentedControlをサブクラス化し、そのフラグをinitWithFrameに次のように追加できると思いました。
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
UIColor *first = [UIColor blueColor];
UIColor *second = [UIColor orangeColor];
UIView *firstView = [[UIView alloc] initWithFrame:CGRectMake(self.bounds.origin.x + 5, self.bounds.origin.y + 5, 10, self.bounds.size.height)];
firstView.backgroundColor = first;
[self addSubview:firstView];
}
return self;
}
CustomSegmentedControlオブジェクトをインスタンス化すると、青い長方形が表示されますが、他の元のsegmentedcontrol描画ロジックは表示されません。何かご意見は?ありがとう。