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