#import "ViewController.h"
@interface ViewController ()
{
UIProgressView *progressView;
BOOL isFill;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
isFill = NO;
progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
[self.view addSubview:progressView];
progressView.frame = CGRectMake(10,100,300,100);
//progressView.center=CGPointMake(160,100);
progressView.progress = 0.1;
progressView.tintColor = [UIColor redColor];
progressView.trackTintColor = [UIColor greenColor];
//progressView.progressImage = [UIImage imageNamed:@"loading_0.png"];
}
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
//[progressView setProgress:arc4random()%10/10.0 animated:YES];
if(progressView.progress==1.0){
isFill = YES;
}else if(progressView.progress==0.0){
isFill = NO;
}
if(!isFill) {
float f = progressView.progress + 0.5;
[progressView setProgress:f animated:YES];
}else{
float f = progressView.progress - 0.5;
[progressView setProgress:f animated:YES];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
UIProgressView
最新推荐文章于 2024-04-28 17:19:55 发布