给控件设置圆角
//MARK: 设置某个圆角
func configSideRadius(iv: UIView) {
//MARK: 设置阴影,圆角,一定要根据 屏幕的尺寸/self的bounds 设定;不能使用自身尺寸
let bounds = CGRect.init(x: 0, y: 0, width: self.bounds.width - 30, height: (self.bounds.width - 30) * 29 / 65)
let maskPath = UIBezierPath.init(roundedRect: bounds, byRoundingCorners: [.topLeft, .topRight], cornerRadii: CGSize(width: 5, height: 5))
let maskLayer = CAShapeLayer.init()
maskLayer.path = maskPath.cgPath
iv.layer.mask = maskLayer
}
本文介绍如何在SwiftUI中为控件设置特定的圆角效果。通过使用UIBezierPath和CAShapeLayer来实现自定义圆角,并调整阴影效果以适应不同屏幕尺寸。
327

被折叠的 条评论
为什么被折叠?



