Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Apply card view cornerRadius & shadow like iOS appstore in swift 4

Tags:

I want to apply "cornerRadius" and card view "shadow" in my collection view cell like iOS appstore today View.

CardView shadow example 1

iOS appstore today view

like image 752
Rahul Singha Roy Avatar asked Jun 29 '18 06:06

Rahul Singha Roy


1 Answers

Just add a subview to the cell and manipulate it's layer property. Tweak the values to your liking. The following code should give a similar result to how it looks in the App Store:

    // The subview inside the collection view cell
    myView.layer.cornerRadius = 20.0
    myView.layer.shadowColor = UIColor.gray.cgColor
    myView.layer.shadowOffset = CGSize(width: 0.0, height: 0.0)
    myView.layer.shadowRadius = 12.0
    myView.layer.shadowOpacity = 0.7

enter image description here

like image 125
oyvindhauge Avatar answered Sep 21 '22 00:09

oyvindhauge