【发布时间】:2021-05-18 02:52:48
【问题描述】:
我尝试添加曲线,但不起作用。
图片左边是设计师给的,右边是我快速完成的。
如果添加曲线拐角半径不起作用,则如果我添加拐角半径不适用于曲线。
我已经添加了左侧和右侧单独的视图,如何实现删除超级视图背景颜色和曲线。
extension UIView {
func roundCorners(
corners: UIRectCorner,
radius: CGFloat
) {
let path = UIBezierPath(
roundedRect: bounds,
byRoundingCorners: corners,
cornerRadii: CGSize(
width: radius,
height: radius
)
)
let mask = CAShapeLayer()
mask.path = path.cgPath
layer.mask = mask
}
}
// here I am using on UITableviewCell in layoutSubview
leftCurve.roundCorners(corners: [.topRight,.bottomRight], radius: 20)
rightCurver.roundCorners(corners: [.topLeft,.bottomLeft], radius: 20)
【问题讨论】:
-
也可以设置半圆形图片为图片视图
-
曲线不可能? @KishanBhatiya
-
我说的是另一种方法,而不是使用
UIBezierPath进行绘图
标签: ios objective-c swift uiview layer