1. 程式人生 > >iOS--UIProgressView的使用方法詳細

iOS--UIProgressView的使用方法詳細

// UIProgressView的使用 常用於歌曲的和下載的進度條

    UIProgressView *oneProgressView = [[UIProgressView allocinit];

    oneProgressView.frame = CGRectMake(03032030); // 設定UIProgressView的位置和大小

    oneProgressView.backgroundColor = [UIColor clearColor]; // 設定背景色

    oneProgressView.alpha = 1.0; // 設定透明度 範圍在0.0-1.0之間 0.0為全透明

    oneProgressView.progressTintColor = [UIColor yellowColor]; // 設定已過進度部分的顏色

    oneProgressView.trackTintColor = [UIColor blackColor]; // 設定未過進度部分的顏色

    oneProgressView.progress = 0.2; // 設定初始值,範圍在0.0-1.0之間,預設是0.0

 // [oneProgressView setProgress:0.8 animated:YES]; // 設定初始值,可以看到動畫效果

    [oneProgressView setProgressViewStyle:

UIProgressViewStyleDefault]; // 設定顯示的樣式

 // 新增到View上,並釋放記憶體

    [self.view addSubview:oneProgressView];

    [oneProgressView release], oneProgressView = nil;