Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add shadow to image in UIKit

I have this screen with an UIImageView (the image is a SF Symbol)

The user can see this icon clearly, white on black. But - if the background is different:

It may be hard to see it. I want to add a black shadow to the image so the user can see it better.

I tried looking online but all I saw is how to add shadow to the image view box, and that is not what I need. I need the shadow around the icon itself and not around the box of the image.

Any ideas? thanks in advance

like image 634
אורי orihpt Avatar asked Sep 06 '25 15:09

אורי orihpt


1 Answers

Try this:

imageView.layer.shadowColor = UIColor.black.cgColor
imageView.layer.shadowRadius = 3.0
imageView.layer.shadowOpacity = 1.0
imageView.layer.shadowOffset = CGSize(width: 4, height: 4)
imageView.layer.masksToBounds = false
like image 51
Daisy the cat Avatar answered Sep 08 '25 12:09

Daisy the cat