ios - 带动画圆形旋转的进度条
#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 - 带动画圆形旋转的进度条的更多相关文章
- 纯CSS炫酷3D旋转立方体进度条特效
在网站制作中,提高用户体验度是一项非常重要的任务.一个创意设计不但能吸引用户的眼球,还能大大的提高用户的体验.在这篇文章中,我们将大胆的将前面所学的3D立方体和进度条结合起来,制作一款纯CSS3的3D ...
- ios swift 实现饼状图进度条,swift环形进度条
ios swift 实现饼状图进度条 // // ProgressControl.swift // L02MyProgressControl // // Created by plter on 7/2 ...
- iOS带动画的环形进度条(进度条和数字同步)
本篇写的是实现环形进度条,并带动画效果,要实现这些,仅能通过自己画一个 方法直接看代码 为了方便多次调用,用继承UIView的方式 .m文件 #import <UIKit/UIKit.h> ...
- Android 自定义view --圆形百分比(进度条)
转载请注明出处:http://blog.csdn.net/wingichoy/article/details/50334595 注:本文由于是在学习过程中写的,存在大量问题(overdraw onDr ...
- 自定义控件之圆形颜色渐变进度条--SweepGradient
前几天在群里面有人找圆形可颜色渐变进度条,其中主要的知识点是SweepGradient: mSweepGradient = new SweepGradient(240, 360, new int[] ...
- IOS中公布应用程序,进度条一直不走怎么处理
在IOS中公布应用程序非常是喜闻乐见. 近期1周.我更新了6次版本号.可是时不时的会卡住,进度条不走. 最后总结了几个原因. 1.在公布前你要确认自己的证书是否配置正确 2.DNS域名server有没 ...
- iOS WKWebView添加网页加载进度条(转)
一.效果展示 WKWebProgressViewDemo.gif 二.主要步骤 1.添加UIProgressView属性 @property (nonatomic, strong) WKWebView ...
- js动画 无缝轮播 进度条 文字页面展示 div弹窗遮罩效果
1.无缝轮播 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.a ...
- iOS 自定义任意形状加载进度条(水波纹进度条)
1. 项目中要做类似下面的加载动画: 先给出安卓的实现方式 2.iOS的实现方式参考了下面两位的,感谢. 以任意底部图片为背景的加载动画 和 水波纹动画 最后附上自己的demo
随机推荐
- HDU 5858 Hard problem (数学推导)
Hard problem 题目链接: http://acm.split.hdu.edu.cn/showproblem.php?pid=5858 Description cjj is fun with ...
- Controlling GameObjects Using Components
[Accessing Components] The most common case is where a script needs access to other Components attac ...
- GWT工程架构分析与理解
上一篇文章中介绍了GWT技术的一些理论性的东西,涉及到GWT得一些技术原理及实现.接下来笔者将通过创建一个GWT工程去理解分析GWT工程架构. GWT工程架构解析 笔者使用的是Eclipse插 ...
- POJ1948Triangular Pastures(DP)
POJ1948http://poj.org/problem?id=1948 题目大意就是说给你n个木棍让你用它们摆成一个三角形 使得这个三角形的面积最大. 这个题我之前想的时候一直纠结怎么通过之前的 ...
- JavaScript事件处理的三种方式(转)
一.什么是JavaScript事件? 事件(Event)是JavaScript应用跳动的心脏,也是把所有东西粘在一起的胶水,当我们与浏览器中Web页面进行某些类型的交互时,事件就发生了. 事件可能是用 ...
- JS:公历、农历互转
先申明这段代码不是我写的,纯粹只是觉的比较好用,所以记录下来以后继续使用,也同样分享给大家,大家有更好的可以推荐给我,谢谢! function CalConv(M, dateStr) { if (da ...
- 深入理解c++中char*与wchar_t*与string以及wstring之间的相互转换 [转]
本篇文章是对c++中的char*与wchar_t*与string以及wstring之间的相互转换进行了详细的分析介绍,需要的朋友参考下. #ifndef USE_H_ #define USE_H_ # ...
- JPA的主键生成策略
数据的唯一性是很平常的要求,但是如果框架不能提供相关的控制而由程序员完全控制是很危险的,在JPA中,有下面四种策略.A.容器自动生成---GeneratorType.AUTO 由JPA自动生成B.使用 ...
- Flex Builder 开发语言切换问题
1.Flex Builder 4.6切换语言 打开\Adobe\Adobe Flash Builder 4.6\FlashBuilder.ini -nlzh_CN-startupeclipse/plu ...
- NLog官方文档
NLog快速使用 NLog配置 NLog通过代码定义配置 Target Layouts Layout Renderers