Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView section shadow [duplicate]

How to achieve the tableView section shadow in UITableViewController.

like image 579
nik Avatar asked Mar 28 '16 12:03

nik


1 Answers

Add this method to get drop shadow of UITableView Section This answer is in Swift3

func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
    let shadowView = UIView()
    let gradient = CAGradientLayer()
    gradient.frame.size = CGSize(width: tableView.bounds.width, height: 15)

    let stopColor = UIColor.gray.cgColor    
    let startColor = UIColor.white.cgColor    

    gradient.colors = [stopColor, startColor]    
    gradient.locations = [0.0,0.8]

    shadowView.layer.addSublayer(gradient)    

    return shadowView
}
like image 70
Mohsin Qureshi Avatar answered Oct 17 '22 08:10

Mohsin Qureshi