请帮我做一个像 UILabel 这样的简单角标(Badge)。
我的代码是:
let badgeLabel = UILabel(frame: CGRectMake(0, 0, 25, 25))
badgeLabel.backgroundColor = UIColor.clearColor()
badgeLabel.layer.backgroundColor = UIColor.redColor().CGColor
badgeLabel.layer.cornerRadius = 25/2
badgeLabel.layer.borderWidth = 3.0
badgeLabel.layer.borderColor = UIColor.whiteColor().CGColor
结果我得到了一个 UILabel,在白色边框上有一个红色的小笔划:
最佳答案
试试这个。
让badgeLabel = UILabel(frame: CGRectMake(0, 0, 25, 25))
badgeLabel.backgroundColor = UIColor.redColor()
badgeLabel.layer.backgroundColor = UIColor.clearColor().CGColor
角标(Badge)标签.layer.cornerRadius = 25/2
badgeLabel.layer.borderWidth = 3.0
badgeLabel.layer.borderColor = UIColor.whiteColor().CGColor
关于iOS 角标(Badge)像 UILabel 故障,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28171886/