1
UISegmentedControlに少し色付いたインジケータ(単色の矩形)を追加します。私はUISegmentedControlをサブクラス化し、このようにinitWithFrameでそのフラグを追加すると考えていた:私はCustomSegmentedControlオブジェクトをインスタンス化するときUISegmentedControlをサブクラス化して、各セグメントにカラーUIViewを追加します。
- (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;
}
が、私はちょうど青い四角形を取得しますが、他の元segmentedcontrol描画ロジックのどれも。何かご意見は?ありがとう。
色付き矩形の画像を設定することができます。私は同じ問題がありますが、私は全体のセット.pngsを使用することから離れようとしています。私もサブクラス化しようとしています。 – piperchester