【发布时间】:2021-04-14 11:19:22
【问题描述】:
如何用弧尾的文字创建像这张图片一样的自定义弓
这是我当前的代码和当前结果
let center = view.center
let circularPath = UIBezierPath(arcCenter: center, radius: 120, startAngle: CGFloat.pi , endAngle: CGFloat.pi*2, clockwise: true)
let greyLayer = CAShapeLayer()
greyLayer.strokeColor = greyColor
greyLayer.lineWidth = lineWidth
greyLayer.path = circularPath.cgPath
greyLayer.lineCap = .round
greyLayer.fillColor = UIColor.clear.cgColor
greyLayer.shadowColor = UIColor.black.cgColor
greyLayer.shadowOpacity = 1
greyLayer.shadowOffset = .zero
greyLayer.shadowRadius = 2
view.layer.addSublayer(greyLayer)
shapeLayer.strokeColor = bowColor
shapeLayer.lineWidth = lineWidth
shapeLayer.path = circularPath.cgPath
shapeLayer.lineCap = .round
shapeLayer.strokeEnd = 0
shapeLayer.fillColor = UIColor.clear.cgColor
view.layer.addSublayer(shapeLayer)
view.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(handleTap)))
let label = UILabel()
label.text = "Best"
label.textAlignment = .center
label.textColor = .red
label.font = UIFont.boldSystemFont(ofSize: 30)
view.addSubview(label)
view.layer.addSublayer(label.layer)
label.translatesAutoresizingMaskIntoConstraints = false
label.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
label.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
label.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
label.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
当前结果 我想在圆弧的末端添加一个圆形并像上图一样动画, 我不知道如何实现这个
【问题讨论】: