kar*_*yan 0 cashapelayer ios swift
我正在尝试添加一个CAShapeLayer到UILabel.
问题是:这样做后文本消失了:
let shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPath
shapeLayer.fillColor = UIColor.yellow.cgColor
item.layer.addSublayer(shapeLayer)
Run Code Online (Sandbox Code Playgroud)
有没有其他方法可以做到这一点?
我解决了这个问题,通过将 Lable 添加到UIView 中,我们必须插入如下图层
let shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPat
shapeLayer.fillColor = UIColor.yellow.cgColor
item.layer.insertSublayer(shapeLayer, at: 0)
Run Code Online (Sandbox Code Playgroud)
item对象将是您的UIView
我试图添加图层,所以它不能正常工作。
item.layer.addSublayer(shapeLayer)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1047 次 |
| 最近记录: |