2011-07-31 18 views

答えて

3

アップルのドキュメントでは、これをプログラム的に行う方法は明記されていません。これを行う最も簡単な方法は、セグメント化された各制御セグメントのテキストを表示せずにスクリーンショットを撮ることです。その後、Photoshopやgimpを開いて、好きな色で目的のテキストを追加します。私は、これは古い問題であると認識

UIImage *segmentOne = [[UIImage imageNamed:@"segmentOne.png"] stretchableImageWithLeftCapWidth:4 topCapHeight:0]; 
UIImage *segmentTwo = [[UIImage imageNamed:@"segmentTwo.png"] stretchableImageWithLeftCapWidth:4 topCapHeight:0]; 
[_segmentedControl setImage:segmentOne forSegmentAtIndex:0]; 
[_segmentedControl setImage:segmentTwo forSegmentAtIndex:1]; 
0

が、それはこの上の最初の関連するヒットとなった。そして、その(2つのセグメントを想定して)同じようにあなたにあなたのイメージをスライダを教えてください。

UICatalogから近代的な方法は、次のとおりです。

NSDictionary *textAttributes = @{ UITextAttributeTextColor:[UIColor blueColor], 
            UITextAttributeFont:[UIFont systemFontOfSize:13.0] }; 
[segmentedControl setTitleTextAttributes:textAttributes 
           forState:UIControlStateNormal]; 

textAttributes = @{ UITextAttributeTextColor:[UIColor redColor], 
        UITextAttributeFont:[UIFont systemFontOfSize:13.0] }; 
[segmentedControl setTitleTextAttributes:textAttributes 
           forState:UIControlStateHighlighted]; 

setTitleTextAttributes:forState:最初のiOS 5に登場するので、これらの日、それを使用しない理由はありません。

他の言葉:おそらくUITextAttributeTextShadowColorを設定するとよいでしょう。

関連する問題