#import <UIKit/UIKit.h>

@interface TJCircleProgressView : UIView
/**
* 图标
*/
@property(nonatomic,strong)UIImage *imgIcon;
/**
* 进度条值
*/
@property(nonatomic,assign)CGFloat progressValue;
/**
* 进度条宽度
*/
@property(nonatomic,assign)CGFloat progressWidth; /**
* 进度条颜色
*/
@property(nonatomic,strong)UIColor *progressColor; @end
#import "TJCircleProgressView.h"
@interface TJCircleProgressView ()
{
UIBezierPath *circlePath;//布赛尔曲线
CAShapeLayer *shapeLayer;// 圆形图层
CAShapeLayer *imgLayer;//图标图层 }
@end
@implementation TJCircleProgressView
@synthesize progressColor = _progressColor;
@synthesize imgIcon = _imgIcon;
@synthesize progressValue = _progressValue;
@synthesize progressWidth = _progressWidth; - (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame])
{
self.backgroundColor = [UIColor whiteColor];
circlePath = [UIBezierPath bezierPathWithOvalInRect:self.bounds]; shapeLayer = [CAShapeLayer layer];
shapeLayer.frame = self.bounds;
shapeLayer.strokeColor = [UIColor redColor].CGColor;
shapeLayer.fillColor = [UIColor clearColor].CGColor;
shapeLayer.path = circlePath.CGPath; shapeLayer.lineWidth = 1.0f;
[self.layer addSublayer:shapeLayer];
}
return self;
}
- (void)setImgIcon:(UIImage *)imgIcon
{
_imgIcon = imgIcon;
imgLayer = [CAShapeLayer layer];
imgLayer.frame = CGRectMake(, , imgIcon.size.width, imgIcon.size.height);
imgLayer.contents = (__bridge id)imgIcon.CGImage;
imgLayer.position = shapeLayer.position;
[self.layer addSublayer:imgLayer]; }
- (void)setProgressValue:(CGFloat)progressValue
{
_progressValue = progressValue;
shapeLayer.strokeEnd = progressValue;
[self startAnimation];
/**延时4秒后移除动画以及view*/
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)( * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[self stopAnimation];
});
}
- (void)setProgressWidth:(CGFloat)progressWidth
{
_progressWidth = progressWidth;
shapeLayer.lineWidth = progressWidth;
}
- (void)setProgressColor:(UIColor *)progressColor
{
_progressColor = progressColor;
shapeLayer.strokeColor = progressColor.CGColor;
}
-(void)startAnimation
{
[shapeLayer removeAnimationForKey:@"RotationAnimation"]; CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
animation.fromValue = @();
animation.toValue = @(M_PI * );
animation.repeatCount = MAXFLOAT;
animation.duration = 0.5f;
animation.fillMode = kCAFillModeForwards; [shapeLayer addAnimation:animation forKey:@"RotationAnimation"];
}
- (void)stopAnimation
{
[shapeLayer removeAllAnimations];
[self removeFromSuperview];
}
@end
#import "ViewController.h"
#import "TJCircleProgressView.h"
@interface ViewController ()
{
TJCircleProgressView *circleProgressView;
}
@end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
circleProgressView = [[TJCircleProgressView alloc]initWithFrame:CGRectMake(,, , )];
circleProgressView.center = self.view.center;
[circleProgressView setProgressValue:0.75];
[circleProgressView setProgressColor:[UIColor grayColor]];
[circleProgressView setProgressWidth:1.0f];
[circleProgressView setImgIcon:[UIImage imageNamed:@"refresh"]];
[self.view addSubview:circleProgressView]; } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end

ps:licecap录取动画没录好

ios - 带动画圆形旋转的进度条的更多相关文章

  1. 纯CSS炫酷3D旋转立方体进度条特效

    在网站制作中,提高用户体验度是一项非常重要的任务.一个创意设计不但能吸引用户的眼球,还能大大的提高用户的体验.在这篇文章中,我们将大胆的将前面所学的3D立方体和进度条结合起来,制作一款纯CSS3的3D ...

  2. ios swift 实现饼状图进度条,swift环形进度条

    ios swift 实现饼状图进度条 // // ProgressControl.swift // L02MyProgressControl // // Created by plter on 7/2 ...

  3. iOS带动画的环形进度条(进度条和数字同步)

    本篇写的是实现环形进度条,并带动画效果,要实现这些,仅能通过自己画一个 方法直接看代码 为了方便多次调用,用继承UIView的方式 .m文件 #import <UIKit/UIKit.h> ...

  4. Android 自定义view --圆形百分比(进度条)

    转载请注明出处:http://blog.csdn.net/wingichoy/article/details/50334595 注:本文由于是在学习过程中写的,存在大量问题(overdraw onDr ...

  5. 自定义控件之圆形颜色渐变进度条--SweepGradient

    前几天在群里面有人找圆形可颜色渐变进度条,其中主要的知识点是SweepGradient: mSweepGradient = new SweepGradient(240, 360, new int[] ...

  6. IOS中公布应用程序,进度条一直不走怎么处理

    在IOS中公布应用程序非常是喜闻乐见. 近期1周.我更新了6次版本号.可是时不时的会卡住,进度条不走. 最后总结了几个原因. 1.在公布前你要确认自己的证书是否配置正确 2.DNS域名server有没 ...

  7. iOS WKWebView添加网页加载进度条(转)

    一.效果展示 WKWebProgressViewDemo.gif 二.主要步骤 1.添加UIProgressView属性 @property (nonatomic, strong) WKWebView ...

  8. js动画 无缝轮播 进度条 文字页面展示 div弹窗遮罩效果

    1.无缝轮播 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.a ...

  9. iOS 自定义任意形状加载进度条(水波纹进度条)

    1. 项目中要做类似下面的加载动画: 先给出安卓的实现方式 2.iOS的实现方式参考了下面两位的,感谢. 以任意底部图片为背景的加载动画 和 水波纹动画 最后附上自己的demo

随机推荐

  1. html5 +css3 第一章学习和笔记

    各位同学.身为本版的斑竹.,希望各位童鞋都能学到Html5 .特此没两天更新一个学习笔记和大家一起学习Html5.... 语法改变       1.新增的元素和废除的元素       2.新增的属性和 ...

  2. URAL 2068 Game of Nuts (博弈)

    题意:给定 n 堆石子,每次一个人把它们分成三堆都是奇数的,谁先不能分,谁输. 析:因为每堆都是奇数,那么最后肯定都是要分成1的,那么就把不是1的全加和,然后判断奇偶就OK了. 代码如下: #prag ...

  3. 解决sencha touch显示.JSON包含中文数据时显示乱码问题

    按照ST官方示例navigationview做的一个示例.数据源是一个.json文件.但是显示的时候如果.json文件里有中文则乱码.我知道是编码问题,但是不知道怎么改,如何改. 问了N个人最后解决方 ...

  4. 【Netbeans】表格的使用

    参数两个:一个二维数组赋予数据,一个一位数组赋予属性名

  5. MES取所有部门的函数实例

    USE [ChangHong]GO/****** Object: UserDefinedFunction [dbo].[FN_GetDeptCode] Script Date: 04/26/2016 ...

  6. (剑指Offer)面试题29:数组中出现次数超过一半的数字

    题目: 数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字. 例如输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}.由于数字2在数组中出现了5次,超过数组长度的一半,因此输出2. ...

  7. Flex编程注意之直接获取某个组件的对象(this[]用法)通过id获取控件

    有这样一个需求:假如你new了一百次Button,同时这些button的id分别赋值如btn1.id = "button1"; btn2.id = "button2&qu ...

  8. Vehicle’s communication protocol

    http://www.crecorder.com/techInfo/commuProtocols.jsp COMMUNICATION PROTOCOLS A “communication protoc ...

  9. JQUERY插件JqueryAjaxFileUplaoder----更简单的异步文件上传

    异步上传相信大家都做过类似的功能,JqueryAjaxFileUploader为我们提供了更简单的实现和使用方式.不过既然是JQUERY的插件那么它所依赖的环境大家都懂得.JqueryAjaxFile ...

  10. HDU 5590 ZYB's Biology 水题

    ZYB's Biology Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...