IOS 之圓形 ProgressView

來源:互聯網
上載者:User

標籤:style   class   blog   code   http   tar   

今天有個需求要製作圓形的UIProgressView 我採用的是一個開源的DACircularProgress,給大家分享一下

一,介紹:

1.GitHub:https://github.com/danielamitay/DACircularProgress

2.最後如下:




二.步驟:

1.從GitHub下載DACircularProgress ,解壓縮

2.把DACircularProgress檔案夾拖入項目中

3.添加<QuartzCore.framework>.架構

4.在ViewController中添加標頭檔 #import "DACircularProgressView.h"

5.使用如下:

self.progressView = [[DACircularProgressView alloc] initWithFrame:CGRectMake(140.0f, 30.0f, 40.0f, 40.0f)];self.progressView.roundedCorners = YES;self.progressView.trackTintColor = [UIColor clearColor];[self.view addSubview:self.progressView];

轉載請註明,本文轉自:http://blog.csdn.net/wildcatlele

6.我做的項目要求進度有一個遞增的進度,在我項目中使用如下,很簡單直接上代碼:

#import "ViewController.h"//#import "WeekDay.h"//#import "GetCityAQI.h"//#import "CityAQI.h"//#import "TestView.h"#import "DACircularProgressView.h"#import "DALabeledCircularProgressView.h"#define TIMER_DURATION 5#define AQI_FULL 500@interface ViewController (){    DACircularProgressView *progressView;    DALabeledCircularProgressView *labeledProgressView;    int start;    int aqi;    }@property (nonatomic,retain )NSTimer *timer;@end@implementation ViewController- (void)viewDidLoad{    [super viewDidLoad];     [self setProgressView];}#pragma mark - 進度條-(void)setProgressView{    //設定空氣品質指數    aqi=200;    //初始化進度條視圖    progressView = [[DACircularProgressView alloc] initWithFrame:CGRectMake(140.0f, 200.0f, 100.0f, 100.0f)];    progressView.roundedCorners = NO;    //設定顏色    progressView.trackTintColor = [UIColor grayColor];    progressView.progressTintColor=[UIColor greenColor];    //設定進度    [progressView setProgress:(CGFloat)aqi/AQI_FULL animated:YES initialDelay:0.5];            labeledProgressView= [[DALabeledCircularProgressView alloc]                          initWithFrame:CGRectMake(140.0f, 200.0f, 100.0f, 100.0f)];    labeledProgressView.progressLabel.textColor=[UIColor blueColor];    [self.view addSubview:labeledProgressView];    [self.view addSubview:progressView];        [self startAnimation];}#pragma mark 開始啟動定時器 標籤內容自加- (void)startAnimation{    self.timer= [NSTimer scheduledTimerWithTimeInterval:(CGFloat)TIMER_DURATION/aqi                                                  target:self                                                selector:@selector(progressChange)                                                userInfo:nil                                                 repeats:YES];}#pragma mark 改變標籤內容- (void)progressChange{    labeledProgressView.progressLabel.text = [NSString stringWithFormat:@"%d", start+=1];    if (start>=aqi) {        [self.timer invalidate];        self.timer = nil;    }}@end

轉載請註明,本文轉自:http://blog.csdn.net/wildcatlele












聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.