简体   繁体   中英

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:

图片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:

图片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!

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: 在此处输入图片说明

you need to add some space: 在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM