我想在運行時在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)
}