FS.O6
FS.O6

Reputation: 1464

Adding shadow to UIView on top of UITableView

I have a VC that has a UITableView all over the screen, except the first 66px from the top. There, I have a custom UIView I call "Toolbar" which contains a title and a button.

It looks like this:

Image 1

I'm trying to add a shadow to the "Toolbar" that will be visible on top of the UITableView. I'm adding it like this:

Image 2

For some reason, I don't see any shadow when I run the app.

What am I doing wrong? Does anybody know?

Thank you!

Upvotes: 0

Views: 792

Answers (1)

Mina
Mina

Reputation: 2222

Shadow needs some spaces to be shown, you have to add some vertical spaces between your top view(toolbar) and the Table view.

for having a result like the following: enter image description here

you need to add some space: enter image description here

ans I also use the following code for adding the shadow:

toolbar.layer.shadowColor = UIColor.black.cgColor
toolbar.layer.shadowOpacity = 1
toolbar.layer.shadowOffset = CGSize.zero
toolbar.layer.shadowRadius = 10
toolbar.layer.masksToBounds = false

Upvotes: 1

Related Questions