2

Uiprogressview でカスタム プログレス ビューを使用しており、20 秒以内に固定色で塗りつぶされていますが、10 秒後に別の色で塗りつぶされるようにしたいので、2 秒後には 2 のように見えます色付きの円、ここに私のコードがあります:

#import "CEViewController.h"

@interface CEViewController ()
{

}


@end

@implementation CEViewController

@synthesize progressView;
@synthesize progressSlider;
@synthesize playPauseButton;
@synthesize player;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    self.player = [[[CEPlayer alloc] init] autorelease];
    self.player.delegate = self;

    UIColor *tintColor = [UIColor orangeColor];
    [[UISlider appearance] setMinimumTrackTintColor:tintColor];
    [[CERoundProgressView appearance] setTintColor:tintColor];

    self.progressView.trackColor = [UIColor colorWithWhite:0.80 alpha:1.0];

    self.progressView.startAngle = (3.0*M_PI)/2.0;

}

- (void)viewDidUnload
{
    [self setProgressView:nil];
    [self setProgressSlider:nil];
    [self setPlayPauseButton:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (void)dealloc {
    [progressView release];
    [progressSlider release];
    self.player = nil;
    [playPauseButton release];
    [super dealloc];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (IBAction)progressSlider:(UISlider *)sender 
{
    self.player.position = sender.value;
    self.progressView.progress = sender.value;
}

- (IBAction)playPauseButton:(UIButton *)sender 
{
    if(sender.selected) // Shows the Pause symbol
    {
        sender.selected = NO;
        [self.player pause];
    }
    else    // Shows the Play symbol
    {
        sender.selected = YES;
        [self.player play];
    }
}



// MARK: CEPlayerDelegate methods

- (void) player:(CEPlayer *)player didReachPosition:(float)position
{
    self.progressView.progress = position;
    self.progressSlider.value = position;
}

- (void) playerDidStop:(CEPlayer *)player
{
    self.playPauseButton.selected = NO;
    self.progressView.progress = 0.0;
    self.progressSlider.value = 0.0;    
}
@end

目的の出力を得るにはどこを変更すればよいですか、助けてください

4

1 に答える 1

1

otherColorこれを試して、後半の色に置き換えてください。いくつかの構文エラーを修正する必要があるかもしれません。私のバージョンの Xcode はこのコンピューターでは実行できないため、確認できませんでした。

#import "CEViewController.h"

@interface CEViewController ()
{
UIColor *progressColor;
BOOL colorChanged;
}


@end

@implementation CEViewController

@synthesize progressView;
@synthesize progressSlider;
@synthesize playPauseButton;
@synthesize player;
@synthesize progressColor;
@synthesize colorChanged;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    self.player = [[[CEPlayer alloc] init] autorelease];
    self.player.delegate = self;

    self.progressColor= [UIColor orangeColor];
    [[UISlider appearance] setMinimumTrackTintColor:self.progressColor];
    [[CERoundProgressView appearance] setTintColor:self.progressColor];

    self.progressView.trackColor = [UIColor colorWithWhite:0.80 alpha:1.0];

    self.progressView.startAngle = (3.0*M_PI)/2.0;
    colorChanged = false;
}

- (void)viewDidUnload
{
    [self setProgressView:nil];
    [self setProgressSlider:nil];
    [self setPlayPauseButton:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (void)dealloc {
    [progressView release];
    [progressSlider release];
    self.player = nil;
    [playPauseButton release];
    [super dealloc];
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (IBAction)progressSlider:(UISlider *)sender 
{
    self.player.position = sender.value;
    if(sender.value >= 0.5 && colorChanged == false) {
        self.progressColor= [UIColor otherColor];
        [[UISlider appearance] setMinimumTrackTintColor:self.progressColor];
        [[CERoundProgressView appearance] setTintColor:self.progressColor];
        colorChanged = true;
    }
    self.progressView.progress = sender.value;
}

- (IBAction)playPauseButton:(UIButton *)sender 
{
    if(sender.selected) // Shows the Pause symbol
    {
        sender.selected = NO;
        [self.player pause];
    }
    else    // Shows the Play symbol
    {
        sender.selected = YES;
        [self.player play];
    }
}



// MARK: CEPlayerDelegate methods

- (void) player:(CEPlayer *)player didReachPosition:(float)position
{
    self.progressView.progress = position;
    self.progressSlider.value = position;
}

- (void) playerDidStop:(CEPlayer *)player
{
    self.playPauseButton.selected = NO;
    self.progressView.progress = 0.0;
    self.progressSlider.value = 0.0;    
}
@end
于 2013-01-02T00:13:00.347 に答える