【发布时间】:2015-08-16 03:50:54
【问题描述】:
我正在使用 UIBezierPath 让我的 imageview 有圆角,但我也想为 imageview 添加一个边框。请记住,顶部是 uiimage,底部是标签。
当前使用此代码产生:
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 的边框?
【问题讨论】:
-
这真的不是那么容易 - 在我下面的回答中,我试图解决所涉及的不幸的微妙之处。
-
嗨@gooberboobbutt!这么久了,你认为你能在我的回答上打勾吗!谢谢! :)
-
你好 @gooberboobbutt - 为 2019 年提供完美的现代解决方案 :) 享受
标签: swift uibezierpath