CAShapeLayer 到 UILabel 隐藏文本
CAShapeLayer to UILabel hides text
我正在尝试将 CAShapeLayer
添加到 UILabel
。
问题是:文本在这样做后消失:
let shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPath
shapeLayer.fillColor = UIColor.yellow.cgColor
item.layer.addSublayer(shapeLayer)
还有其他方法吗?
我通过将 Lable 添加到 UIView 中解决了这个问题,并且我们必须像下面那样 insert layer
let shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPat
shapeLayer.fillColor = UIColor.yellow.cgColor
item.layer.insertSublayer(shapeLayer, at: 0)
item 对象将是您的 UIView
我曾尝试 addLayer 所以它没有正常工作。
item.layer.addSublayer(shapeLayer)
我正在尝试将 CAShapeLayer
添加到 UILabel
。
问题是:文本在这样做后消失:
let shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPath
shapeLayer.fillColor = UIColor.yellow.cgColor
item.layer.addSublayer(shapeLayer)
还有其他方法吗?
我通过将 Lable 添加到 UIView 中解决了这个问题,并且我们必须像下面那样 insert layer
let shapeLayer = CAShapeLayer()
shapeLayer.path = path.cgPat
shapeLayer.fillColor = UIColor.yellow.cgColor
item.layer.insertSublayer(shapeLayer, at: 0)
item 对象将是您的 UIView
我曾尝试 addLayer 所以它没有正常工作。
item.layer.addSublayer(shapeLayer)