I'm new to Material design. I have custom collectionView cells in Main.storyboard
, which contains some labels, buttons and Imageview. I want to load my custom cell as MDCCardCollectionCell
.
When i use this code, I'm getting the empty MDCCardCollectionCell
. It crashes the Application
collectionView.register(MDCCardCollectionCell.self, forCellWithReuseIdentifier: "Cell")
func collectionView(_ collectionView: UICollectionView,
cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell",
for: indexPath) as! MDCCardCollectionCell
cell.cornerRadius = 8
cell.setShadowElevation(6, for: .selected)
cell.setShadowColor(UIColor.black, for: .highlighted)
return cell
}
When i load custom collectionView cells without this line its loaded successfully from Main.storyboard
but the MDCCard
styles is not applying (shadow effect).
collectionView.register(MDCCardCollectionCell.self, forCellWithReuseIdentifier: "Cell")
Thanks
You can subclass your collectionViewCell from MDCCardCollectionCell and then use it.