Ios 如何使用Beizer路径添加阴影

Ios 如何使用Beizer路径添加阴影,ios,swift,uitableview,shadow,Ios,Swift,Uitableview,Shadow,我已经在视图的三个面上添加了阴影,没有给出底部阴影,但在初始加载时,它会在所有角上显示阴影,但当我滚动时,它会显示正确的结果。这是我的密码 类ScheduleClassesTableViewCell:UITableViewCell{ let path = UIBezierPath() //MARK:- //MARK:- IBOUTLETS @IBOutlet weak var cellImage: UIImageView! @IBOutlet weak var openTime: UILab

我已经在视图的三个面上添加了阴影,没有给出底部阴影,但在初始加载时,它会在所有角上显示阴影,但当我滚动时,它会显示正确的结果。这是我的密码

类ScheduleClassesTableViewCell:UITableViewCell{

let path = UIBezierPath()

//MARK:-
//MARK:- IBOUTLETS

@IBOutlet weak var cellImage: UIImageView!
@IBOutlet weak var openTime: UILabel!
@IBOutlet weak var closeTime: UILabel!
@IBOutlet weak var clockImage: UIImageView!
@IBOutlet weak var instructerNameLabel: UILabel!
@IBOutlet weak var classTypeLabel: UILabel!
@IBOutlet weak var healthClubLocationLabel: UILabel!
@IBOutlet weak var ratingsBtn: UIButton!
@IBOutlet weak var locationBtn: UIButton!
@IBOutlet weak var healthClubName: UILabel!
@IBOutlet weak var healthClubLoc: UILabel!
@IBOutlet weak var shadowView: UIView!

//MARK:-
//MARK:- TableView Life Cycle

override func awakeFromNib() {
    super.awakeFromNib()

    self.healthClubLoc.isHidden = false
    self.ratingsBtn.doCorner(cornerRadius: 2.5)
    self.locationBtn.doCorner(cornerRadius: 2.5)
    self.ratingsBtn.setBorder(with: UIColor.gray, of: 0.5)
    self.locationBtn.setBorder(with: UIColor.white, of: 1.0)
    self.cellImage.doCorner(cornerRadius: 2.5)
}

override func draw(_ rect: CGRect) {
    super.draw(rect)
    self.shadowView.layoutIfNeeded()
    path.move(to: CGPoint(x: 0.0, y: shadowView.frame.size.height))
    path.addLine(to: CGPoint(x: 0.0, y: 0.0))
    path.addLine(to: CGPoint(x: shadowView.frame.size.width, y: 0.0))
    path.addLine(to: CGPoint(x: shadowView.frame.size.width, y: shadowView.frame.size.height))
    self.shadowView.drawShadow(shadowColor: UIColor.red, shadowOpacity: 0.8, shadowPath: path, shadowRadius: 2, cornerRadius: 0.0)

}


请更新您的代码

请帮助删除下角的红色阴影。
override func draw(_ rect: CGRect) {
    super.draw(rect)

    path.move(to: CGPoint(x: 0.0, y: shadowView.frame.size.height))
    path.addLine(to: CGPoint(x: 0.0, y: 0.0))
    path.addLine(to: CGPoint(x: shadowView.frame.size.width, y: 0.0))
    path.addLine(to: CGPoint(x: shadowView.frame.size.width, y: shadowView.frame.size.height))
    self.shadowView.drawShadow(shadowColor: UIColor.red, shadowOpacity: 0.8, shadowPath: path, shadowRadius: 2, cornerRadius: 0.0)
    layoutIfNeeded()

}