How to achieve the tableView section shadow in UITableViewController.
Asked
Active
Viewed 6,719 times
6
-
You want this shadow in the section header write? or in the whole section – HardikDG Mar 28 '16 at 12:38
-
Not in section header. I want shadow in whole section. Check the image attached above those are separate sections. – nik Mar 28 '16 at 12:40
-
Found a way to achieve it. check [this](http://stackoverflow.com/questions/18822619/ios-7-tableview-like-in-settings-app-on-ipad) – nik Mar 28 '16 at 14:06
1 Answers
8
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
}

Mohsin Qureshi
- 1,203
- 2
- 16
- 26
-
-
1the question is about the section NOT section header or footer only! – Vyachaslav Gerchicov Apr 27 '21 at 10:48