我试图在运行时在TableViewCell的单元格中围绕标签绘制一个圆圈.
我可以弄清楚如何在标签周围大致得到它,但是我很难将它集中在标签周围.
圆圈似乎正在向标签的右侧和中间绘制.
到目前为止,这是我的代码,我相信这对于某人来说很容易.
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)
}
Run Code Online (Sandbox Code Playgroud) 我有一个带有一个TableView的TableViewController,它有自动布局动态设置的行.
我已经向Controller添加了另一个TableView,用于菜单.它的行高需要设置为65.
问题是,在heightForRowAtIndexPath中.我知道如何为这个tableView菜单的行返回65.但我不知道如何让自动布局为其他tableView做的事情仍然存在.
有谁知道我怎么能做到这一点?
这是我的代码:
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
if tableView is YALContextMenuTableView {
return 65
} else {
}
}
Run Code Online (Sandbox Code Playgroud)