下の図のように中央のセルが強調表示されるUICollectionViewがあります。UICollectionViewが影付きのセルを強調表示しました
私は、中心セルの周りに影を作るために、次のコードを使用しています。
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell : STSuggestStyleCell = collectionView.dequeueReusableCell(for: indexPath)
if indexPath.row == 4{
cell.imageProfile.layer.cornerRadius = 2.0
cell.imageProfile.layer.borderWidth = 1.0;
cell.imageProfile.layer.borderColor = UIColor.clear.cgColor
cell.imageProfile.layer.masksToBounds = true;
cell.imageProfile.layer.shadowColor = UIColor.lightGray.cgColor;
cell.imageProfile.layer.shadowOffset = CGSize(width: 2.0, height: 2.0);
cell.imageProfile.layer.shadowRadius = 2.0;
cell.imageProfile.layer.shadowOpacity = 2.0;
cell.imageProfile.layer.masksToBounds = false;
cell.imageProfile.layer.shadowPath = UIBezierPath(roundedRect: cell.imageProfile.bounds, cornerRadius: cell.imageProfile.layer.cornerRadius).cgPath
cell.imageProfile.backgroundColor = UIColor.white
}
return cell
}
しかし、正しく動作しません。
誰でもUICollectionViewを使用して上記のデザインを達成する方法を教えてもらえますか?
私は既に上記の解決策を試しています。それは動作していません。 –
@ Aman.Sanghaniあなたは影を見ることができますか?または細胞の内側の影? –
はいそれは働いた。ありがとうございました:) –