当前位置: 首页 > news >正文

横峰县城乡建设网站嘉祥做网站

横峰县城乡建设网站,嘉祥做网站,深圳今天新闻头条,在线网站备案做项目让做一个加载动画,一个圈圈在转中间加一个图片,网上有好多demo,这里我也自己写了一个,中间的图片可加可不加。其中主要用到贝塞尔曲线。UIBezierPath是对CGContextRef的进一步封装,不多说直接上代码#xff1a; #import UIKit/UIKit.hinterface CircleLoader : …做项目让做一个加载动画,一个圈圈在转中间加一个图片,网上有好多demo,这里我也自己写了一个,中间的图片可加可不加。其中主要用到贝塞尔曲线。UIBezierPath是对CGContextRef的进一步封装,不多说直接上代码 #import UIKit/UIKit.hinterface CircleLoader : UIView//进度颜色 property(nonatomic, retain) UIColor* progressTintColor ;//轨道颜色 property(nonatomic, retain) UIColor* trackTintColor ;//轨道宽度 property (nonatomic,assign) float lineWidth;//中间图片 property (nonatomic,strong) UIImage *centerImage;//进度 property (nonatomic,assign) float progressValue;//提示标题 property (nonatomic,strong) NSString *promptTitle;//开启动画 property (nonatomic,assign) BOOL animationing;//隐藏消失 - (void)hide;end #import CircleLoader.hinterface CircleLoader ()property (nonatomic,strong) CAShapeLayer *trackLayer;property (nonatomic,strong) CAShapeLayer *progressLayer;endimplementation CircleLoader- (instancetype)initWithFrame:(CGRect)frame {self [super initWithFrame:frame];if (self) {self.backgroundColor[UIColor clearColor];}return self; } -(void)drawRect:(CGRect)rect {[super drawRect:rect];_trackLayer[CAShapeLayer layer];_trackLayer.frameCGRectMake(0, 0, self.frame.size.width, self.frame.size.height);_trackLayer.lineWidth_lineWidth;_trackLayer.strokeColor_trackTintColor.CGColor;_trackLayer.fillColor self.backgroundColor.CGColor;_trackLayer.lineCap kCALineCapRound;[self.layer addSublayer:_trackLayer];_progressLayer[CAShapeLayer layer];_progressLayer.frameCGRectMake(0, 0, self.frame.size.width, self.frame.size.height);_progressLayer.lineWidth_lineWidth;_progressLayer.strokeColor_progressTintColor.CGColor;_progressLayer.fillColor self.backgroundColor.CGColor;_progressLayer.lineCap kCALineCapRound;[self.layer addSublayer:_progressLayer];if (_centerImage!nil) {UIImageView *centerImgView[[UIImageView alloc]initWithImage:_centerImage];centerImgView.frameCGRectMake(_lineWidth, _lineWidth, self.frame.size.width-2*_lineWidth, self.frame.size.height-_lineWidth*2); // centerImgView.centerself.center;centerImgView.layer.cornerRadius(self.frame.size.width_lineWidth)/2;centerImgView.clipsToBoundsYES;[self.layer addSublayer:centerImgView.layer];}[self start]; }- (void)drawBackgroundCircle:(BOOL) animationing {//贝塞尔曲线 0度是在十字右边方向 M_PI/2相当于在十字上边方向CGFloat startAngle - ((float)M_PI / 2); // 90 Degrees//CGFloat endAngle (2 * (float)M_PI) - ((float)M_PI / 8);;CGPoint center CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2);CGFloat radius (self.bounds.size.width - _lineWidth)/2;UIBezierPath *processPath [UIBezierPath bezierPath]; // processPath.lineWidth_lineWidth;UIBezierPath *trackPath [UIBezierPath bezierPath]; // trackPath.lineWidth_lineWidth;//---------------------------------------// Make end angle to 90% of the progress//---------------------------------------if (!animationing) {endAngle (_progressValue * 2*(float)M_PI) startAngle;}else{endAngle (0.1 * 2*(float)M_PI) startAngle;}[processPath addArcWithCenter:center radius:radius startAngle:startAngle endAngle:endAngle clockwise:YES];[trackPath addArcWithCenter:center radius:radius startAngle:0 endAngle:2*M_PI clockwise:YES];_progressLayer.path processPath.CGPath;_trackLayer.pathtrackPath.CGPath; } - (void)start {[self drawBackgroundCircle:_animationing];if (_animationing) {CABasicAnimation *rotationAnimation [CABasicAnimation animationWithKeyPath:transform.rotation.z];rotationAnimation.toValue [NSNumber numberWithFloat:M_PI * 2.0];rotationAnimation.duration 1;rotationAnimation.cumulative YES;rotationAnimation.repeatCount HUGE_VALF;[_progressLayer addAnimation:rotationAnimation forKey:rotationAnimation];}} - (void)hide {[_progressLayer removeAllAnimations];[self removeFromSuperview]; } end 调用: #import ViewController.h #import CircleLoader.hinterface ViewController ()endimplementation ViewController- (void)viewDidLoad {[super viewDidLoad];// Do any additional setup after loading the view, typically from a nib.//设置视图大小CircleLoader *view[[CircleLoader alloc]initWithFrame:CGRectMake(100, 100, 70, 70)];//设置轨道颜色view.trackTintColor[UIColor redColor];//设置进度条颜色view.progressTintColor[UIColor greenColor];//设置轨道宽度view.lineWidth5.0;//设置进度view.progressValue0.7;//设置是否转到 YES进度不用设置view.animationingYES;//添加中间图片 不设置则不显示view.centerImage[UIImage imageNamed:yzp_loading];//添加视图[self.view addSubview:view];dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{//视图隐藏 // [view hide];});}- (void)didReceiveMemoryWarning {[super didReceiveMemoryWarning];// Dispose of any resources that can be recreated. }end 效果: 转载于:https://www.cnblogs.com/5ishare/p/4810437.html
http://www.huolong8.cn/news/350969/

相关文章:

  • 电商网站开发意义iis7搭建网站织梦
  • 做竞彩网站代理犯法么做网站攻略
  • 网站收录查询工具规划设计公司网站
  • 石家庄网络推广建站是短视频迅猛发展的非常重要的因素
  • 静态企业网站下载池州网站优化公司
  • 给个龙做罗拉的网站梅州市建设局网站
  • 北京网站建设hj华网天下知乎 wordpress插件
  • 网站做水印有没有影响吗广告公司推广平台
  • 门户网站建设情况报告中装建设重组消息
  • 下载百度官方网站wordpress 清空浏览量
  • 专业做网站哪家便宜推广平台有哪些渠道
  • 企业网站打不开什么原因中国能建招商平台
  • 我要找个做网站的公司子域名网址大全
  • wordpress在线代码编辑器seo网站推广专员招聘
  • 如何做建筑一体化的网站做网站的基本知识
  • 学校门户网站建设工作汇报小程序游戏免广告神器
  • 建设企业学习网站在线一键建站系统
  • 阳江网站制作企业微信app
  • 在网站上部署淘宝联盟推广代码的推广模式.哪家网站专门做折扣销售
  • 网站取消备案重庆网站建站建设的费用
  • 哪些网站是vue做的网站模块数据同步
  • 网站开发公司模板海南做网站的技术公司
  • 公司网站建设费用入账dean's fckeditor for wordpress
  • 英语网站大全免费可信赖的邢台做网站
  • 曲周住房和城乡建设局网站免费建立微网站
  • 哪个网站域名更新快在哪个网做免费网站好
  • 有没有做羞羞事的网站免费h5页面制作软件app
  • 无刷新网站俄文网站设计
  • 如何查询网站的注册信息主题猫仿虎嗅wordpress
  • 网站蓝色导航栏代码ztjs登录