0

を設定するとtintColor、選択したボタンが表示されなくなります。valueChanged イベントは引き続き発生しますが、選択したボタンの色は変化しません。コントロールをデフォルトの青いスタイルのままにせずに、選択したボタンを表示する方法はありませんか?UISegmentedControlsegmentedControlStyleUISegmentedControlStyleBar

4

2 に答える 2

0

暗い色を TintColor として設定すると、選択された効果が得られません。このコードを UISegmentControl の変更メソッドに入れるなど、明るい色を使用するためです。

for (int i=0; i<[[sender subviews] count]; i++)
{
    if ([[[sender subviews] objectAtIndex:i]isSelected] )
    {
        UIColor *tintcolor=[UIColor redColor]; //your requiremnent color here
        [[[sender subviews] objectAtIndex:i] setTintColor:tintcolor];
        break;
    }
}

これを試して

于 2013-03-25T12:11:03.987 に答える
0

で選択したセグメントに色を追加UISegmentcontrol

差出人はこちらUISegmentControl

for (int i=0; i<[sender.subviews count]; i++) 
{
    if ([[sender.subviews objectAtIndex:i]isSelected] ) 
    {               
    UIColor *tintcolor=[UIColor colorWithRed:127.0/255.0 green:161.0/255.0 blue:183.0/255.0 alpha:1.0];
    [[sender.subviews objectAtIndex:i] setTintColor:tintcolor];
    break;
    }
}
于 2013-03-25T12:15:38.820 に答える