Create the shadow as a transparent layer at a particular size, then create a stretchable image, like this:
UIImage *shadowImage = [UIImage imageNamed:@"shadow.png"];
shadowImage = [shadowImage stretchableImageWithLeftCapWidth:floorf(shadowImage.size.width/2) topCapHeight:floorf(shadowImage.size.height/2)];
You can then put that as the image in a UIImageView with contentMode scale to fit and it will work the way you want.
Lets say your view is called "myView". You can add the shadow like this:
UIImageView *shadowImageView = [[UIImageView alloc] initWithImage:shadowImage];
shadowImageView.contentMode = UIViewContentModeScaleToFill;
shadowImageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
shadowImageView.frame = myView.bounds;
[myView addSubview:shadowImageView];
[shadowImageView release]; // only needed if you aren't using ARC
You can also do most of this in interface builder if you prefer, as long as you create the stretchable image itself in code.