iOS:進度條控件的詳細使用


進度條控件:UIProcessView:UIView

 
功能:顧名思義,用來顯示下載進度或者傳輸數據進度。
 
屬性:

@property(nonatomic) UIProgressViewStyle progressViewStyle; //風格類型

@property(nonatomic) float progress;                                   //當前進度

@property(nonatomic, retain) UIColor* progressTintColor;        //進度條進度的高亮顏色

@property(nonatomic, retain) UIColor* trackTintColor;            //進度條軌道的高亮顏色

@property(nonatomic, retain) UIImage* progressImage;            //進度條進度的圖像

@property(nonatomic, retain) UIImage* trackImage;               //進度條軌道的圖像

 

風格:

typedef NS_ENUM(NSInteger, UIProgressViewStyle) {

    UIProgressViewStyleDefault,     //默認的風格,一種灰白色的風格 (有進度顯示的部分默認為藍色)

    UIProgressViewStyleBar,         //沒有進度顯示時是無色的風格 (有進度顯示的部分默認為藍色)

 

};

 

方法:

※初始化進度條實例

- (instancetype)initWithProgressViewStyle:(UIProgressViewStyle)style;

※設置進度條並且帶有動畫效果

- (void)setProgress:(float)progress animated:(BOOL)animated

 

舉例如下:

//創建進度條實例

    //創建進度條實例
    UIProgressView *processView = [[UIProgressView alloc]initWithProgressViewStyle:UIProgressViewStyleDefault];

//設置進度條的frame

    //設置它的frame
    processView.frame = CGRectMake(60, 80,250, 40);

//將控件添加到視圖中

    //添加該控件到視圖View中
    [self.view addSubview:processView];

此時的進度條結果為:

 

//設置進度

    //設置進度
    processView.progress = 0.5;

此時的進度條結果為:

//設置軌道的顏色

    //設置它的軌道顏色
    processView.trackTintColor = [UIColor redColor];

此時的進度條結果為:

//設置進度條進度的顏色

    //設置進度的顏色
    processView.progressTintColor = [UIColor greenColor];

此時的進度條結果為:

 

 

設置進度條進度和動畫效果

    //設置進度條進度的動畫
    [processView setProgress:0.8 animated:YES];

演示結果如下:

------> 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM