0

次のコードを使用してオーディオ ビジュアライザーを表示しています。基本的に、左入力用と右入力用の 2 つのバーが表示されます。これらは正常に動作しますが、四角形の色を変更する方法があるかどうかを知りたいので、たとえば、ピーク電力は赤になりますが、通常の値はまだ緑のバーになりますか? これが私のコードです。

    - (void)drawRect:(CGRect)rect {

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, [UIColor greenColor].CGColor);
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
CGContextFillRect(context, CGRectMake(15.0, 10.0, kMeterViewFullWidth * leftValue, 15.0));
CGContextFillRect(context, CGRectMake(15.0, 35.0, kMeterViewFullWidth * rightValue, 15.0));
} else {
    CGContextFillRect(context, CGRectMake(15.0, 10.0, kMeterViewFullWidthiPad * leftValue, 15.0));
    CGContextFillRect(context, CGRectMake(15.0, 35.0, kMeterViewFullWidthiPad * rightValue, 15.0));
}
CGContextFlush(context);
}
4

1 に答える 1