Applying drop shadow to UIImageView array
I have an array UIImageViews
. I want to apply shadow to each of these images. I used the following code:
- (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 also included #import <QuartzCore/CALayer.h>
.
I am not getting any errors, but I also have no shadows in my images.
source to share
Are you sure this code is being called? Have you set a breakpoint in the loop for
for checking?
-awakeFromNib
only called if you have a view (or whatever) in a nib file connected via IBOutlet
an ivar in your code. -awakefFromNib
is called in this case instead of -initWithFrame:
(or the like), an important distinction that I sometimes forget!
source to share