I am trying to draw a circle around a label at runtime in a TableViewCell cell.
I can understand how to get it around the mark, but I have some problems with focusing it around the mark.
The circle seems to be drawn to the right and closer to the middle of the mark.
Here is my code so far, I'm sure it will be easy for someone to run out of steam.
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)
}
source
share