我想在运行时在TableViewCell的单元格中围绕标签绘制一个圆。Swift:围绕标签绘制一个圆
我可以弄清楚如何将它粗略地放在标签的周围,但我在将标签集中在标签周围时遇到了一些麻烦。
圆圈似乎正在绘制到右侧和朝向标签的中间。
这是我的代码到目前为止,我敢肯定,这将很容易有人轰炸。
func drawCircle() {
let x = countLabel.layer.position.x - (countLabel.frame.width)
let y = countLabel.layer.position.y - (countLabel.frame.height/2)
let circlePath = UIBezierPath(roundedRect: CGRectMake(x, y, countLabel.frame.height, countLabel.frame.height), cornerRadius: countLabel.frame.height/2).CGPath
let circleShape = CAShapeLayer()
circleShape.path = circlePath
circleShape.lineWidth = 3
circleShape.strokeColor = UIColor.whiteColor().CGColor
circleShape.fillColor = UIColor.clearColor().CGColor
self.layer.addSublayer(circleShape)
}