我有ProfileCollectionViewCell
一种方法:
func configureCellWithProfile(profile: Profile) {
shapeLayer.removeFromSuperlayer()
let path = CGPathCreateMutable()
CGPathMoveToPoint(path, nil, 0, 0)
CGPathAddLineToPoint(path, nil, CGRectGetWidth(likeButton.frame), 0)
CGPathAddLineToPoint(path, nil, CGRectGetWidth(likeButton.frame), CGRectGetHeight(likeButton.frame))
CGPathCloseSubpath(path)
shapeLayer.fillColor = profile.favourite ? UIColor.brilliantRose().CGColor : UIColor.blackSqueeze().CGColor
shapeLayer.path = path
likeButton.layer.masksToBounds = true
likeButton.layer.addSublayer(shapeLayer)
}
刚加载后它看起来像这样:
但在我滚动标题后(来自icomoon字体的心脏)消失了:
为什么吗
答案 0 :(得分:2)
我解决了这个问题,取而代之的是:
likeButton.layer.addSublayer(shapeLayer)
与
likeButton.layer.insertSublayer(shapeLayer, below: likeButton.titleLabel?.layer)