Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does shadowOffset do in iOS exactly?

Tags:

ios

ios7

I couldn't find this info anywhere so asking here.

What does element.layer.shadowOffset = CGSizeMake(2.0, 2.0)] do exactly?

What offset does it indicate with respect to the element?

like image 488
user2810114 Avatar asked Jan 27 '14 14:01

user2810114


People also ask

What is shadowOffset?

ShadowOffset is a CGSize representing how far to offset the shadow from the path. The default value of this property is (0.0, -3.0).

What is shadowOffset in Swift?

shadowColor : this will allow us to set the color of our shadow. shadowColor is a CGColor . shadowOffset : this will allow us to offset the shadow from the layer. shadowOffset is a CGRect where the width will move the shadow left and right and the height will move the shadow up and down.

What is shadow radius?

shadowRadius : the blur radius used to render the layer's shadow. A value of zero creates a hard-edged shadow that exactly matches the shape of the view. A larger value creates a soft-edged shadow that looks more natural. The default value of this property is 3.0 .

How do you add a shadow in UIView?

iOS has built-in support for adding shadows to UIView components. All you need to do in order to add a shadow to a UIView object is to set the shadow properties of the view's layer. Shadows are a powerful user interface design element, making the visual components stand out by giving them a 3D look and feel.


1 Answers

The shadowOffset value changes the location of the shadow with respect to the element's frame. An offset of (2,2) will put the shadow 2 pixels to the right and 2 pixels down with respect to the element. An offset of (15,45) will put the shadow 15 pixels to the right and 45 pixels down. These can also be negative values if you want the shadow to be to the top or left of the element.

And by pixels I mean units. Based off the original (non-retina) pixel sizes of apple devices.

like image 181
Putz1103 Avatar answered Sep 19 '22 20:09

Putz1103