博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS-Quart2D 进度条
阅读量:5011 次
发布时间:2019-06-12

本文共 2401 字,大约阅读时间需要 8 分钟。

////  HMProgressView.h//  进度条////  Created by YaguangZhu on 15/9/9.//  Copyright (c) 2015年 YaguangZhu. All rights reserved.//#import 
@interface HMProgressView : UIView@property(nonatomic,assign)CGFloat progress;@end//// HMProgressView.m// 进度条//// Created by YaguangZhu on 15/9/9.// Copyright (c) 2015年 YaguangZhu. All rights reserved.//#import "HMProgressView.h"@interface HMProgressView()@property(nonatomic,weak)UILabel *label;@end@implementation HMProgressView- (UILabel *)label{ if (_label == nil) { UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; label.textAlignment = NSTextAlignmentCenter; [self addSubview:label]; _label = label; } return _label;}- (void)setProgress:(CGFloat)progress{ _progress = progress; self.label.text = [NSString stringWithFormat:@"%.2f%%",progress*100]; [self setNeedsDisplay];}// Only override drawRect: if you perform custom drawing.// An empty implementation adversely affects performance during animation.- (void)drawRect:(CGRect)rect { // Drawing code CGContextRef ctx = UIGraphicsGetCurrentContext(); CGPoint center = CGPointMake(50, 50); CGFloat startA = -M_PI_2; CGFloat radius = 50-2; CGFloat endA = -M_PI_2 +_progress * M_PI *2; UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:startA endAngle:endA clockwise:YES]; CGContextAddPath(ctx, path.CGPath); CGContextStrokePath(ctx); }@end
////  ViewController.h//  进度条////  Created by YaguangZhu on 15/9/9.//  Copyright (c) 2015年 YaguangZhu. All rights reserved.//#import 
@interface ViewController : UIViewController@end//// ViewController.m// 进度条//// Created by YaguangZhu on 15/9/9.// Copyright (c) 2015年 YaguangZhu. All rights reserved.//#import "ViewController.h"#import "HMProgressView.h"@interface ViewController ()@property (weak, nonatomic) IBOutlet HMProgressView *progressView;@end@implementation ViewController- (IBAction)valueChange:(UISlider *)sender { _progressView.progress = sender.value;}- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib.}- (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}@end

 

转载于:https://www.cnblogs.com/zhuyaguang/p/4794994.html

你可能感兴趣的文章
Google Map API V3开发(6) 代码
查看>>
Kafka初入门简单配置与使用
查看>>
第三章Git使用入门
查看>>
Amd,Cmd, Commonjs, ES6 import/export的异同点
查看>>
cocos2dx-Lua与Java通讯机制
查看>>
上下文管理器之__enter__和__exit__
查看>>
android3.2以上切屏禁止onCreate()
查看>>
winform文件迁移工具
查看>>
delphi DCC32命令行方式编译delphi工程源码
查看>>
paip.输入法编程----删除双字词简拼
查看>>
or1200下raw-os学习(任务篇)
查看>>
ZOJ - 3939 The Lucky Week(日期循环节+思维)
查看>>
小花梨的取石子游戏(思维)
查看>>
Ubuntu 18.04安装arm-linux-gcc交叉编译器
查看>>
.net core i上 K8S(一)集群搭建
查看>>
django drf 深入ModelSerializer
查看>>
Android---Menu菜单
查看>>
【资源导航】我所用到过的工具及下载地址
查看>>
监控Tomcat
查看>>
剑指offer编程题Java实现——面试题4后的相关题目
查看>>