I've been looking for a way to set the shadow
property of a layer, like this:
where the light blue is the layer—the UIImageView
in this instance—and the dark blue is the shadow.
I'd like the shadow to do things:
- Appear on all four sides: accomplished by setting
shadowOffset
toCGSizeMake(0.0, 0.0)
and makingshadowRadius
nonzero - Be entirely opaque: accomplished by setting
shadowOffset
to a specific point in the layer andshadowRadius
to zero
I already have shadowOpacity
set to zero, but I can't find a way to do both of these. For example, if I have:
imageView.layer.shadowColor = UIColor.orangeColor().CGColor
imageView.layer.shadowOffset = CGSizeMake(4.0 , 4.0)
imageView.layer.shadowOpacity = 1;
imageView.layer.shadowRadius = 0
imageView.layer.masksToBounds = false
I get a solid shadow on two sides. If I want the shadow to be on all four sides, I change shadowOffset
to a specific size and shadowRadius
to something greater than zero, but then it's not solid.