UITableViewCell shadows

前端 未结 2 532
盖世英雄少女心
盖世英雄少女心 2021-01-15 08:47

I\'m trying to implement this design but all solutions I have browsed won\'t work and from what I understand it could be because of the spacing between the cells and the UIT

相关标签:
2条回答
  • 2021-01-15 09:20

    You have to make a UIView inside UITableViewCell and work on that view.

    FOR SHADOW I AM USING THIS IN UITableViewCell CLASS:-

    viewDummy.addShadow() //use from any view
    
    extension UIView {
        func addShadow(){
            self.layer.shadowColor = UIColor.blackColor().CGColor
            self.layer.shadowOpacity = 0.5
            self.layer.shadowRadius = 2.0
            self.layer.shadowOffset = CGSizeMake(1.0, 1.0)
        }
    }
    
    0 讨论(0)
  • 2021-01-15 09:28
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
        cell.layer.shadowOffset = CGSize(width: 0, height: 0)
        cell.layer.shadowColor = UIColor.black.cgColor
        cell.layer.shadowRadius = 5
    
        cell.layer.shadowOpacity = 0.40
        cell.layer.masksToBounds = false;
        cell.clipsToBounds = false;
        return cell
    }
    
    0 讨论(0)
提交回复
热议问题