我使用UIBezierPath让我的imageview有圆角,但我也想添加一个边框到imageview。请记住,顶部是一个uiimage,底部是一个标签。UIBezierPath:如何在带圆角的视图周围添加边框?
目前使用此代码生成:
let rectShape = CAShapeLayer()
rectShape.bounds = myCell2.NewFeedImageView.frame
rectShape.position = myCell2.NewFeedImageView.center
rectShape.path = UIBezierPath(roundedRect: myCell2.NewFeedImageView.bounds,
byRoundingCorners: .TopRight | .TopLeft,
cornerRadii: CGSize(width: 25, height: 25)).CGPath
myCell2.NewFeedImageView.layer.mask = rectShape
我想绿色边框添加到这一点,但我不能使用
myCell2.NewFeedImageView.layer.borderWidth = 8
myCell2.NewFeedImageView.layer.borderColor = UIColor.greenColor().CGColor
,因为它切断左上角和在此图像中看到的边框的右上角:
有没有办法在我的当前代码中添加与UIBezierPath的边界?
这真的不是那么容易做到这一点 - 在我的回答下面,我试图解决涉及不幸的微妙之处 – Fattie