Closed Zss1990 closed 1 year ago
库很棒,给作者点赞!👍🏻 在使用中发现 UIView+Extension中5.2、添加圆角和边框 方法: // MARK: 5.2、添加圆角和边框 /// 添加圆角和边框 /// - Parameters: /// - conrners: 具体哪个圆角 /// - radius: 圆角的大小 /// - borderWidth: 边框的宽度 /// - borderColor: 边框的颜色 func addCorner(conrners: UIRectCorner , radius: CGFloat, borderWidth: CGFloat, borderColor: UIColor) { let maskPath = UIBezierPath(roundedRect: self.base.bounds, byRoundingCorners: conrners, cornerRadii: CGSize(width: radius, height: radius)) let maskLayer = CAShapeLayer() maskLayer.frame = self.base.bounds maskLayer.path = maskPath.cgPath self.base.layer.mask = maskLayer
// Add border let borderLayer = CAShapeLayer() borderLayer.path = maskLayer.path borderLayer.fillColor = UIColor.clear.cgColor borderLayer.strokeColor = borderColor.cgColor borderLayer.lineWidth = borderWidth borderLayer.frame = self.base.bounds self.base.layer.addSublayer(borderLayer) }
存在图层报错问题,borderLayer这里设置是否有问题?请大佬帮忙看下
代码没问题的,您这边是怎么使用的?方便的话我加您个微信或者您加我(wangc2318151015)
暂时没复现
库很棒,给作者点赞!👍🏻 在使用中发现 UIView+Extension中5.2、添加圆角和边框 方法: // MARK: 5.2、添加圆角和边框
/// 添加圆角和边框 /// - Parameters: /// - conrners: 具体哪个圆角 /// - radius: 圆角的大小 /// - borderWidth: 边框的宽度 /// - borderColor: 边框的颜色 func addCorner(conrners: UIRectCorner , radius: CGFloat, borderWidth: CGFloat, borderColor: UIColor) { let maskPath = UIBezierPath(roundedRect: self.base.bounds, byRoundingCorners: conrners, cornerRadii: CGSize(width: radius, height: radius)) let maskLayer = CAShapeLayer() maskLayer.frame = self.base.bounds maskLayer.path = maskPath.cgPath self.base.layer.mask = maskLayer
存在图层报错问题,borderLayer这里设置是否有问题?请大佬帮忙看下