答案 0 :(得分:3)
将阴影创建为特定大小的透明图层,同时创建可伸缩图像,如下所示:
UIImage *shadowImage = [UIImage imageNamed:@"shadow.png"];
shadowImage = [shadowImage stretchableImageWithLeftCapWidth:floorf(shadowImage.size.width/2) topCapHeight:floorf(shadowImage.size.height/2)];
将图像放在UIImageView中,并将contentMode作为适合的比例。
将您的视图称为“sView”。您可以像这样添加阴影:
UIImageView *shadowImgView = [[UIImageView alloc] initWithImage:shadowImage];
shadowImgView.contentMode = UIViewContentModeScaleToFill;
shadowImgView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
shadowImgView.frame = sView.bounds;
[sView shadowImgView];
[shadowImgView release]; // only needed if you aren't using ARC
答案 1 :(得分:0)
您可以尝试使用多张图片(因为它适用于html),但我认为它不比您的示例更好: