试试这个
像这样创建两个UIView
- Set corner radius to the backView
- Set corner radius to the frontView, only for rightBottom and rightTop portions by using below method
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
}
}
参考我的代码
https://github.com/leninsmannath/CardViewSample.git