【发布时间】:2017-04-29 21:36:58
【问题描述】:
我正在尝试使 UIView 的 topLeft 和 bottomLeft 角变圆,但是由于某种原因,只有 topLeft 具有边框半径。这是什么原因造成的?
这就是我正在做的事情:
我有扩展:
extension UIView {
func roundCorners(_ corners: UIRectCorner, radius: CGFloat) {
let path = UIBezierPath(roundedRect: self.bounds, byRoundingCorners: corners, cornerRadii: CGSize(width: radius, height: radius))
let mask = CAShapeLayer()
mask.path = path.cgPath
self.layer.mask = mask
}
}
我将它应用于这样的视图:
myView.roundCorners([.topLeft, .bottomLeft], radius: 10.0)
我在单元格内使用它,我也在使用自动布局。
目前它看起来像这样(绿色是我正在谈论的视图)但我希望 bottomLeft 也有角半径:
【问题讨论】:
-
几周前我遇到了类似的问题。我能够通过增加视图的宽度/高度来解决它。不知道为什么...
标签: ios swift uiview uibezierpath