Search code examples
ioscalayershadow

Drop a shadow to right and bottom of uiview


I have to drop a shadow to the right and bottom of uiview.Im doing this in interface builder.But I see the shadow dropped to top of it.Tried differnt sizes.but couldn't get it.

layer.masksToBound=No
layer.shadowOpacity=0.15
layer.shadowRadius=2
layer.shadowOffSet={10,-10}   //Values being set in Interfacebuilder.

Still this drops shadow at top.What should I do to get at bottom of view.


Solution

  • Try the following code, it might help you

        myView.layer.shadowColor = [UIColor purpleColor].CGColor;
        myView.layer.shadowOffset = CGSizeMake(5, 5);
        myView.layer.shadowOpacity = 1;
        myView.layer.shadowRadius = 1.0;
        myView.layer.maskToBounds = NO;
    

    I tested this code and it's working and output is:

    enter image description here