我正在尝试在视图中添加CALayer,显示了图层,但隐藏了文本。 我的代码如下:
let label = UILabel(frame: CGRect(x: 100, y: 100, width: 25, height: 25))
label.text = "5"
label.font = .boldSystemFont(ofSize: 10)
label.adjustsFontSizeToFitWidth = true
label.textColor = #colorLiteral(red: 0.4392156899, green: 0.01176470611, blue: 0.1921568662, alpha: 1)
label.textAlignment = .center
let sublayer = label.layer
sublayer.backgroundColor = UIColor.yellow.cgColor
sublayer.borderColor = UIColor.red.cgColor
self.view.layer.addSublayer(sublayer)
能否让我知道我要去哪里错了?
谢谢