views:

103

answers:

2

I am trying to create a drop shadow for an image. I also have an animation between views and this is the backdrop. However, when I use the following code, the image is not drawn. Anyone have any ideas?

self.frontViewBackground = [[[UIView alloc] initWithFrame:frame] autorelease];
//self.frontViewBackground.image = [UIImage imageNamed:@"whitepaper3.png"];
self.frontViewBackground.multipleTouchEnabled = YES;
[self.photoView addSubview:self.frontViewBackground];

UIImage *image = [UIImage imageNamed:@"whitepaper3.png"]; 

CGContextRef ctx = UIGraphicsGetCurrentContext();

CGContextSetShadow(ctx, CGSizeMake(1, -2), 3.0);
[image drawInRect:self.frontViewBackground.frame blendMode:kCGBlendModeNormal alpha:1.0];
CGContextRestoreGState(ctx);
+1  A: 

Have you thought about using CALayer's shadow properties? For example you could do the following:

UIView *view = [[UIView alloc] initWithFrame:frame];
view.layer.shadowColor = [[UIColor blackColor] CGColor];
view.layer.shadowRadius = 5.0

Check out more here: http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html#//apple_ref/occ/instp/CALayer/shadowColor

rickharrison
If you do this, you'll also want to investigate using either `shadowPath` or `shouldRasterize`, as using CALayer shadows with no path and no rasterization is fairly inefficient.
Kevin Ballard
A: 

I found a solution via another persons question. Thanks for all the help! link text

Mark this answered.
bstahlhood
Thanks. New here. :)