Apply a shadow to an array of UIImageView

Go To StackoverFlow.com

3

I have an array of UIImageViews. I want to apply a shadow to each of these images. I've used the code below:

- (void)awakeFromNib {
    for (UIImageView *image in imagesJigsawPieces) {
        image.layer.shadowColor = [UIColor blackColor].CGColor;
        image.layer.shadowOffset = CGSizeMake(-1, -1);
        image.layer.shadowOpacity = 1;
        image.layer.shadowRadius = 5.0;
        image.clipsToBounds = NO; //EDIT: I have also included this with no change
    }
}

I have also included #import <QuartzCore/CALayer.h>.

I am not getting any errors but I am also not getting any shadows on my images.

2012-04-04 14:48
by garethdn


3

Are you certain this code is being called? Have you placed a breakpoint in the for loop to verify?

-awakeFromNib is called only if you have a view (or whatever) in a nib file connected via IBOutlet to an ivar in your code. -awakefFromNib is called, in this case, instead of -initWithFrame: (or the like), an important distinction which I sometimes forget myself!

2012-04-04 14:59
by Mark Granoff
Thank you, i don't how i missed. I wasn't calling the code correctly - it's all working now. Thanks again - garethdn 2012-04-04 15:05
Ads