源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

iOS点击文字按钮变转圈加载效果

  • 时间:2020-06-29 10:06 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:iOS点击文字按钮变转圈加载效果
本文实例为大家分享了iOS点击文字按钮变转圈加载效果的相关代码,供大家参考,具体内容如下 [b]实现效果:[/b] [img]http://files.jb51.net/file_images/article/201605/2016520154443414.gif?2016420154456[/img] [b]实现代码:[/b]
// 画弧线
- (void)drawHalfCircle {
  loadingLayer = [self drawCircle];
   
  // 这个是用于指定画笔的开始与结束点
  loadingLayer.strokeStart = 0.0;
  loadingLayer.strokeEnd = 0.75;
}
 
- (CAShapeLayer *)drawCircle {
  CGRect frame = CGRectMake(0, 0, self.frame.size.height, self.frame.size.height);
  CAShapeLayer *circleLayer = [CAShapeLayer layer];
  // 指定frame,只是为了设置宽度和高度
  circleLayer.frame = frame;
  // 设置居中显示
  circleLayer.position = CGPointMake(self.frame.size.height/2, self.frame.size.height/2);
  // 设置填充颜色
  circleLayer.fillColor = [UIColor clearColor].CGColor;
  // 设置线宽
  circleLayer.lineWidth = 1;
  // 设置线的颜色
  circleLayer.strokeColor = kSelfborderColor.CGColor;
  // 使用UIBezierPath创建路径
  UIBezierPath *circlePath = [UIBezierPath bezierPathWithOvalInRect:frame];
  // 设置CAShapeLayer与UIBezierPath关联
  circleLayer.path = circlePath.CGPath;
  // 将CAShaperLayer放到某个层上显示
  [self.layer addSublayer:circleLayer];
  return circleLayer;
}
以上就是本文的全部内容,希望对大家的学习有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部