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
随机推荐
- Debugging Information in Separate Files
[Debugging Information in Separate Files] gdb allows you to put a program's debugging information in ...
- KMP应用http://acm.hdu.edu.cn/showproblem.php?pid=2594
riemann与marjorie拼接后riemannmarjorie前缀与后缀公共部分为 rie 长度为 3(即next[l] = next[14]的值,l为拼接后的长度)但:aaaa与aa拼接后aa ...
- 成功获取并更改中兴F660光猫的超级用户密码解除四台限制
上次雷雨后更换的中兴的F660光猫还是很不错的,很稳定,不过超级密码确实记不住,找了些资料,今天成功的更改了密码,简要的写出过程以备下次参考: 第一步:获取超级密码(已知用户名telecomadmin ...
- 使用UIGestureRecognizer监听屏幕事件
转载自 http://blog.csdn.net/samguoyi/article/details/7911499 如果只是想获取屏幕点击事件有一个最简单的办法,就是写一个透明的uibutton覆盖 ...
- 结构类模式(四):装饰(Decorator)
定义 动态地将责任附加到对象上.若要扩展功能,装饰者提供了比继承更有弹性的替代方案. 它是通过创建一个包装对象,也就是装饰来包裹真实的对象. 特点 装饰对象和真实对象有相同的接口.这样客户端对象就能以 ...
- OC:内存管理、dealloc方法、copy知识点
属性的声明:使⽤@property声明属性 例如:@property NSString *name: 相当于@interface中声明了两个⽅法(setter.getter): 属性的实现:使⽤@s ...
- ASP.NET服务器控件在IE10浏览器(非兼容模式)下报脚本错误的可能解决办法
关于IE10出现LinkButton点击无效的情况: 一般高配置的系统如Win7旗舰版SP1系统不会出现这种情况,针对家庭普通版和专业版的用户通过测试都有这种情况,对于开发人员要解决不同 ...
- 窥探EasyMock(1)基础使用篇
EasyMock的应用分为5步: 1. 使用 EasyMock 生成 Mock 对象: SomeInterface mockObj = createMock(SomeInterface.class); ...
- Android平台NDK编程
转自:http://blog.csdn.net/wangbin_jxust/article/details/37389383 之前在进行cocos2dx开发时,已经详细介绍了如何将win32的c++代 ...
- PostgreSQL停止动作观察
实验过程如下: 启动一个客户端: [postgres@cnrd56 bin]$ ./psql psql () Type "help" for help. postgres=# be ...