我試圖在我的iOS應用程序的表格視圖中放置陰影。我嘗試了不同的技術,但還沒有設法解決它。我試圖增加該小區本身的第一層上的陰影:在UITableView單元格上放置陰影不顯示[Swift 3]
cell.layer.shadowColor = UIColor.black.cgColor
cell.layer.shadowOpacity = 1
cell.layer.shadowOffset = CGSize.zero
cell.layer.shadowRadius = 2
這並沒有工作,所以我試圖把盒子上影內容視圖:
cell.contentview.layer.shadowColor = UIColor.black.cgColor
cell.contentview.layer.shadowOpacity = 1
cell.contentview.layer.shadowOffset = CGSize.zero
cell.contentview.layer.shadowRadius = 2
我還嘗試在表視圖單元格中添加具有相同約束的額外視圖,並在該視圖上放置陰影框,但這並未改變結果。 result with extra view and constraints and cornenradius
東西在表視圖特別是以下內容:每節
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
if section != 0 {
return 10
} else {
return 0
}
}
func tableView(_ tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
let header = view as! UITableViewHeaderFooterView
header.tintColor = UIColor.init(netHex: 0xF9FAFD)
}
表視圖的數據都放在單獨的部分,和1排。
看到這個曾經http://stackoverflow.com/questions/43567288/uiview-shadow -cornerradius-not-working/43567400#43567400 –
我嘗試過那裏解釋過的解決方案,但它沒有效果。 –
可以更新問題一次 –