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
随机推荐
- 【全面完美方案】iPhone 4S WiFi变灰 DIY修复方式
这是我在一位台湾网友usaretama发表的一篇帖子中看到的,原帖我发表在维维网 如果你有WiFi开关变灰不能切换.WiFi遇到搜不到AP或搜到了连不上,那您就要注意这篇了. 家人的 iPhone 4 ...
- MAT(1) 小样
一.内存溢出时生成hprof文件 运行参数: -Xms40m -Xmx40m -Xmn20m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=E:\J ...
- 基于MySQL协议的数据库中间层项目Atlas - 360团队
一.简介 Atlas是由 Qihoo 360公司Web平台部基础架构团队开发维护的一个基于MySQL协议的数据中间层项目.它在MySQL官方推出的MySQL-Proxy 0.8.2版本的基础上,修改了 ...
- hdu 3397 Sequence operation(很有意思的线段树题)
Sequence operation Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
- 面向过程MySQL数据库链接操作
刚好今天复习到这个章节,将就发布出来,就当是为自己复习了 //链接数据库 $link = mysqli_connect('localhost/IP地址','用户名','密码','数据库名'); //设 ...
- 2014年QS世界大学排名
新浪教育[微博]讯 近日2014QS世界大学排行榜发布,榜单前十强均为英美名校.其中麻省理工大学以绝对优势位居榜首:英国剑桥大学及帝国理工学院并列排名第二:哈佛大学较去年而言名次略微下降,跌至第四. ...
- 升级xcode时更换appid账户
转自:http://blog.csdn.net/zhuzhihai1988/article/details/39803743 为了免下载安装Xcode,安装时使用了别人提供的Xcode.dmg安装,而 ...
- oracle中substr函数的用法
1.substr(string string, int a, int b) 参数1:string 要处理的字符串 参数2:a 截取字符串的开始位置(起始位置是0) 参数3:b 截取的字符串的长度(而不 ...
- Receive Windows Messages In Your Custom Delphi Class - NonWindowed Control - AllocateHWnd
http://delphi.about.com/od/windowsshellapi/a/receive-windows-messages-in-custom-delphi-class-nonwind ...
- C#与excel互操作的错误无法将类型为“Excel.ApplicationClass”的COM 对象强制转换为接口类型“Excel._Application”
如果您使用的电脑要操作的是office2003而之前使用过office2007使用此方法可解决您的问题 无法将类型为“Microsoft.Office.Interop.Excel.Applicatio ...