2017-02-25 55 views
1

角を丸くして影を落とすカスタムテーブルビューのセルを作成しようとしていましたが、丸みのある角を作成することができましたが、影は角にのみ表示され、影と丸みを帯びた角の両方についてSWIFT UITableViewCellと角の半径と影

答えて

0

cellForRowAt indexPathでコードの下のライト

cell.contentView.layer.cornerRadius = 10 
cell.contentView.layer.shadowColor = UIColor.blue.cgColor 
cell.contentView.layer.shadowRadius = 3 
cell.contentView.layer.shadowOpacity = 1.0     
cell.contentView.clipsToBounds = true 
+0

'cell.contentView.clipsToBounds = true'を実行するとすぐに影が消えます。丸い角?はい、影?いいえ。 – Annjawn

4

、あなたはこのコードを使用することができます:

override func tableView(_ tableView: UICollectionView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 

    let cell = tableView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath) 
    cell.layer.cornerRadius = 10 
    let shadowPath2 = UIBezierPath(rect: cell.bounds) 
    cell.layer.masksToBounds = false 
    cell.layer.shadowColor = UIColor.black.cgColor 
    cell.layer.shadowOffset = CGSize(width: CGFloat(1.0), height: CGFloat(3.0)) 
    cell.layer.shadowOpacity = 0.5 
    cell.layer.shadowPath = shadowPath2.cgPath 
    return cell 
} 

をそして、あなたは値を調整することができ、あなたが買ってあげますあなたのための完全な影!

希望すると助かります!

関連する問題