3

画像のドロップ シャドウを作成しようとしています。ビュー間にアニメーションもあり、これが背景です。ただし、次のコードを使用すると、画像が描画されません。誰にもアイデアはありますか?

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);
4

1 に答える 1

2

CALayerのシャドウプロパティの使用について考えたことはありますか?たとえば、次のようにすることができます。

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

詳細はこちらをご覧ください:http://developer.apple.com/iphone/library/documentation/GraphicsImaging/Reference/CALayer_class/Introduction/Introduction.html#//apple_ref/occ/instp/CALayer/shadowColor

于 2010-08-22T04:16:06.750 に答える