3
我正在尝试为图像创建投影。我也有意见之间的动画,这是背景。但是,当我使用下面的代码时,图像不绘制。有人有主意吗?需要帮助才能在iOS4的uiview中将图像添加到图像中?
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);
如果你这样做,你还需要使用是'shadowPath'或'shouldRasterize'进行调查,如使用CALayer的阴影没有路径,没有光栅化是相当低效的。 – 2010-08-22 04:44:49