*************自定义下载的view的方法

#import "HMProgressView.h"

@interface HMProgressView()

@property (nonatomic, weak) UILabel *label;

@end

@implementation HMProgressView

- (UILabel *)label
{
if (_label == nil) {
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(, , , )];
label.textAlignment = NSTextAlignmentCenter; [self addSubview:label];
_label = label;
}
return _label;
} - (void)setProgress:(CGFloat)progress
{
_progress = progress;
self.label.text = [NSString stringWithFormat:@"%.2f%%",progress * ]; //文字 // [self drawRect:self.bounds];
// 重新绘制
// 在view上做一个重绘的标记,当下次屏幕刷新的时候,就会调用drawRect.
[self setNeedsDisplay];
} // Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
// 当视图显示的时候会调用 默认只会调用一次
- (void)drawRect:(CGRect)rect
{
// Drawing code // 1.获取上下文
CGContextRef ctx = UIGraphicsGetCurrentContext(); // 2.拼接路径
CGPoint center = CGPointMake(, );
CGFloat radius = - ;
CGFloat startA = -M_PI_2;
CGFloat endA = -M_PI_2 + _progress * M_PI * ;
UIBezierPath *path = [UIBezierPath bezierPathWithArcCenter:center radius:radius startAngle:startA endAngle:endA clockwise:YES]; // 3.把路径添加到上下文
CGContextAddPath(ctx, path.CGPath); // 4.把上下文渲染到视图
CGContextStrokePath(ctx); } @end

*******监听

#import "HMViewController.h"

#import "HMProgressView.h"

@interface HMViewController ()
@property (weak, nonatomic) IBOutlet HMProgressView *progressView; //自定义的view @end @implementation HMViewController
- (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

IOS第16天(2,Quartz2D下载进度条)的更多相关文章

  1. 用 CALayer 定制下载进度条控件

    // // RPProgressView.h // CALayer定制下载进度条控件 // // Created by RinpeChen on 16/1/2. // Copyright © 2016 ...

  2. PHP持续保有长连接,利用flush持续更新浏览器UI,下载进度条实现

    如何用PHP+JS实现上传进度条,大部分的人可能都实现过,但是下载呢?如何呢?原理也是差不多的,就是分次读写,每次读多少字节,但是这样的不好就是长连接,一般实现下载进度条常用的两种解决方案是:一种是需 ...

  3. 用CALayer实现下载进度条控件

    用CALayer实现下载进度条 效果: 源码: // // ViewController.m // ProgressView // // Created by YouXianMing on 14/11 ...

  4. CodePush自定义更新弹框及下载进度条

    CodePush 热更新之自定义更新弹框及下载进度 先来几张弹框效果图 非强制更新场景 image 强制更新场景 image 更新包下载进度效果 image 核心代码 这里的热更新Modal框,是封装 ...

  5. python 之实现断点下载与下载进度条

    一.效果图 二.进度条代码 __author__ = 'Yang' import os import time from threading import Thread '''下载进度条''' cla ...

  6. iOS异步下载下载进度条显示

    说到http异步下载,首先要知道其中的关键类. 关键类是NSURLConnection  NSURLRequest NSMutableURLRequest  委托是 NSURLConnectionDo ...

  7. OC - 9.使用Quartz2D绘制下载进度条

    效果图 实现思路 要实现绘图,通常需要自定义一个UIView的子类,重写父类的- (void)drawRect:(CGRect)rect方法,在该方法中实现绘图操作 若想显示下载进度,只需要实例化自定 ...

  8. iOS开发Quartz2D 三 进度条的应用

    一:效果如图: 二:代码 #import "ViewController.h" #import "ProgressView.h" @interface View ...

  9. iOS之小功能模块--彩虹动画进度条学习和自主封装改进

    前言: 首先展示一下这个iOS小示例的彩色进度条动画效果: 阅读本文先说说好处:对于基础不好的读者,可以直接阅读文末尾的"如何使用彩虹动画进度条"章节,然后将我封装好的这个功能模块 ...

随机推荐

  1. hdu3448 01背包+dfs

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=3448 Description 0/1 bag problem should sound f ...

  2. hdu1503 最长公共子序列变形

    题目链接:http://acm.split.hdu.edu.cn/showproblem.php?pid=1503 题意:给出两个字符串 要求输出包含两个字符串的所有字母的最短序列.注意输出的顺序不能 ...

  3. Angular JS 学习之过滤器

    1.过滤器可以使用一个管道字符(|)添加到表达式和指令中: 2.AngularJS过滤器可用于转换数据: **currency:格式化数字为货币格式: **filter:从数组项中选择一个子集: ** ...

  4. 《DSP using MATLAB》示例Example4.9

    收敛域在圆外,对应原始时间序列为右边序列. 上代码: b = 1; a = poly([0.9, 0.9, -0.9]); % compute the polynomials coefficients ...

  5. DSP using Matlab 示例Example2.2

    a. n = -2:10; x = [1:7,6:-1:1]; % generate x(n) [x11,n11] = sigshift(x,n,5); [x12,n12] = sigshift(x, ...

  6. 解决Genymotion无法创建新设备或无法显示设备列表问题

    准备工作: 链接: https://pan.baidu.com/s/1i5v4IBN 密码: jc3m 用2.8的和最新VirtualBox-5.1.10-112026-Win 注意事项: 1.笔记本 ...

  7. SQL 最基本使用

    --创建表 CREATE TABLE TreeData (id INT IDENTITY(1,1) PRIMARY KEY , pid INT ) --为表添加列 ALTER TABLE treeda ...

  8. 数据库的SQL语句创建和主外键删除操作

    create table UserType ( Id ,), Name nvarchar() not null ) go create table UserInfo ( Id ,), LoginPwd ...

  9. docker不稳定 short running containers with -rm failed to destroy

    正常运行以下命令 sudo docker run --rm busybox echo helloworld /var/log/upstart/docker.log 日志如下: // :: POST / ...

  10. JS运动基础

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...